How to use get_minimal_syspath method in prospector

Best Python code snippet using prospector_python

finder.py

Source:finder.py Github

copy

Full Screen

...39 for filepath in self.files:40 yield os.path.abspath(filepath) if abspath else filepath41 def to_absolute_path(self, path):42 return os.path.abspath(os.path.join(self.rootpath, path))43 def get_minimal_syspath(self, absolute_paths=True):44 paths = list(set(map(os.path.dirname, self.files)))45 if absolute_paths:46 paths = list(map(os.path.abspath, paths))47 return [self.rootpath] + paths48class FoundFiles(object):49 def __init__(self, rootpath, files, modules, packages, directories, ignores):50 self.rootpath = rootpath51 self._files = files52 self._modules = modules53 self._packages = packages54 self._directories = directories55 self._ignores = ignores56 def _check(self, filepath, pathlist, abspath=True, even_if_ignored=False):57 path = os.path.relpath(filepath, self.rootpath) if abspath else filepath58 for checkpath, ignored in pathlist:59 if path == checkpath:60 if ignored and not even_if_ignored:61 break62 return True63 return False64 def check_module(self, filepath, abspath=True, even_if_ignored=False):65 return self._check(filepath, self._modules, abspath, even_if_ignored)66 def check_package(self, filepath, abspath=True, even_if_ignored=False):67 return self._check(filepath, self._packages, abspath, even_if_ignored)68 def check_file(self, filepath, abspath=True, even_if_ignored=False):69 return self._check(filepath, self._files, abspath, even_if_ignored)70 def _iter_paths(self, pathlist, abspath=True, include_ignored=False):71 for path, ignored in pathlist:72 if ignored and not include_ignored:73 continue74 if abspath:75 path = self.to_absolute_path(path)76 yield path77 def iter_file_paths(self, abspath=True, include_ignored=False):78 return self._iter_paths(self._files, abspath, include_ignored)79 def iter_package_paths(self, abspath=True, include_ignored=False):80 return self._iter_paths(self._packages, abspath, include_ignored)81 def iter_directory_paths(self, abspath=True, include_ignored=False):82 return self._iter_paths(self._directories, abspath, include_ignored)83 def iter_module_paths(self, abspath=True, include_ignored=False):84 return self._iter_paths(self._modules, abspath, include_ignored)85 def to_absolute_path(self, path):86 return os.path.abspath(os.path.join(self.rootpath, path))87 def get_minimal_syspath(self, absolute_paths=True):88 """89 Provide a list of directories that, when added to sys.path, would enable90 any of the discovered python modules to be found91 """92 # firstly, gather a list of the minimum path to each package93 package_list = set()94 packages = [p[0] for p in self._packages if not p[1]]95 for package in sorted(packages, key=len):96 parent = os.path.split(package)[0]97 if parent not in packages and parent not in package_list:98 package_list.add(parent)99 # now add the directory containing any modules who are not in packages100 module_list = []101 modules = [m[0] for m in self._modules if not m[1]]...

Full Screen

Full Screen

test_file_finder.py

Source:test_file_finder.py Github

copy

Full Screen

...8 root = os.path.join(os.path.dirname(__file__), 'testdata', name)9 files = find_python([], [root], explicit_file_mode=explicit_file_mode)10 expected = [os.path.relpath(os.path.join(root, e).rstrip(os.path.sep)) for e in expected]11 expected.append(files.rootpath)12 actual = files.get_minimal_syspath()13 expected.sort(key=lambda x: len(x))14 self.assertEqual(actual, expected)15class TestSysPath(TestDataMixin, TestCase):16 def test1(self):17 self._assert_find_files('test1', ['', 'somedir'])18 def test2(self):19 self._assert_find_files('test2', [''])20 def test3(self):21 self._assert_find_files('test3', ['package'])22class TestVirtualenvDetection(TestCase):23 def test_is_a_venv(self):24 path = os.path.join(os.path.dirname(__file__), 'testdata', 'venvs', 'is_a_venv')25 self.assertTrue(is_virtualenv(path))26 def test_not_a_venv(self):...

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 prospector 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