How to use _test_files method in lisa

Best Python code snippet using lisa_python

test_Tree.py

Source:test_Tree.py Github

copy

Full Screen

1#-----------------------------------------------------------------------------2# Copyright (c) 2005-2019, PyInstaller Development Team.3#4# Distributed under the terms of the GNU General Public License with exception5# for distributing bootloader.6#7# The full license is in the file COPYING.txt, distributed with this software.8#-----------------------------------------------------------------------------9# This contains tests for the class:``Tree``, see10# https://pyinstaller.readthedocs.io/en/latest/advanced-topics.html#the-tree-class11import os12import pytest13from os.path import join14import PyInstaller.building.datastruct15class Tree(PyInstaller.building.datastruct.Tree):16 # A stripped-down version of PyInstaller.building.datastruct.Tree,17 # not checking guts, but only the `assemble()` step18 def __postinit__(self):19 self.assemble()20TEST_MOD = 'Tree_files'21_DATA_BASEPATH = join(os.path.dirname(os.path.abspath(__file__)), TEST_MOD)22_TEST_FILES = sorted([23 join('subpkg', 'twelve.py'),24 join('subpkg', 'thirteen.txt'),25 join('subpkg', 'init__.py'),26 'two.py',27 'dynamiclib.dylib',28 join('py_files_not_in_package', 'sub_pkg', 'three.py'),29 join('py_files_not_in_package', 'sub_pkg', 'init__.py'),30 join('py_files_not_in_package', 'one.py'),31 join('py_files_not_in_package', 'data', 'eleven.dat'),32 join('py_files_not_in_package', 'ten.dat'),33 'dynamiclib.dll',34 'pyextension.pyd',35 'nine.dat',36 'init__.py',37 'pyextension.so',38])39_PARAMETERS = (40 (None, None, _TEST_FILES),41 ('abc', None, [join('abc', f) for f in _TEST_FILES]),42 (None, ['*.py'], 43 [f for f in _TEST_FILES if not f.endswith('.py')]),44 (None, ['*.py', '*.pyd'], 45 [f for f in _TEST_FILES if not f.endswith(('.py', '.pyd'))]),46 (None, ['subpkg'], 47 [f for f in _TEST_FILES 48 if not f.startswith('subpkg')]),49 (None, ['subpkg', 'sub_pkg'],50 [f for f in _TEST_FILES 51 if not (f.startswith('subpkg') or os.sep+'sub_pkg'+os.sep in f)]),52 ('klm', ['subpkg', 'sub_pkg', '*.py', '*.pyd'],53 [join('klm', f) for f in _TEST_FILES 54 if not (f.startswith('subpkg') or os.sep+'sub_pkg'+os.sep in f or55 f.endswith(('.py', '.pyd')))]),56)57@pytest.mark.parametrize("prefix,excludes,result", _PARAMETERS)58def test_Tree(monkeypatch, prefix, excludes, result):59 monkeypatch.setattr('PyInstaller.config.CONF', {'workpath': '.'})60 tree = Tree(_DATA_BASEPATH, prefix=prefix, excludes=excludes)61 files = sorted(f[0] for f in tree)...

Full Screen

Full Screen

test_pyximport.py

Source:test_pyximport.py Github

copy

Full Screen

1import pyximport; pyximport.install(reload_support=True)2import os, sys3import time, shutil4import tempfile5def make_tempdir():6 tempdir = os.path.join(tempfile.gettempdir(), "pyrex_temp")7 if os.path.exists(tempdir):8 remove_tempdir(tempdir)9 os.mkdir(tempdir)10 return tempdir11def remove_tempdir(tempdir):12 shutil.rmtree(tempdir, 0, on_remove_file_error)13def on_remove_file_error(func, path, excinfo):14 print "Sorry! Could not remove a temp file:", path15 print "Extra information."16 print func, excinfo17 print "You may want to delete this yourself when you get a chance."18def test():19 pyximport._test_files = []20 tempdir = make_tempdir()21 sys.path.append(tempdir)22 filename = os.path.join(tempdir, "dummy.pyx")23 open(filename, "w").write("print 'Hello world from the Pyrex install hook'")24 import dummy25 reload(dummy)26 depend_filename = os.path.join(tempdir, "dummy.pyxdep")27 depend_file = open(depend_filename, "w")28 depend_file.write("*.txt\nfoo.bar")29 depend_file.close()30 build_filename = os.path.join(tempdir, "dummy.pyxbld")31 build_file = open(build_filename, "w")32 build_file.write("""33from distutils.extension import Extension34def make_ext(name, filename):35 return Extension(name=name, sources=[filename]) 36""")37 build_file.close()38 open(os.path.join(tempdir, "foo.bar"), "w").write(" ")39 open(os.path.join(tempdir, "1.txt"), "w").write(" ")40 open(os.path.join(tempdir, "abc.txt"), "w").write(" ")41 reload(dummy)42 assert len(pyximport._test_files)==1, pyximport._test_files43 reload(dummy)44 time.sleep(1) # sleep a second to get safer mtimes45 open(os.path.join(tempdir, "abc.txt"), "w").write(" ")46 print "Here goes the reolad"47 reload(dummy)48 assert len(pyximport._test_files) == 1, pyximport._test_files49 reload(dummy)50 assert len(pyximport._test_files) ==0, pyximport._test_files51 remove_tempdir(tempdir)52if __name__=="__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful