def test_library_files(self): """ creates temp file structure then tests if library_files can find the .herring files in the temp file structure. Finally the temp files are removed. """ base_dir = mkdtemp() files = [ 'herringfile', 'herringlib/__init__.py', 'herringlib/f1.py', 'herringlib/f2.py', 'herringlib/f3.foo', 'herringlib/f4/__init__.py', 'herringlib/f4/herring', 'herringlib/f4/f5.py', 'herringlib/herring', 'herringlib/herringfile' ] try: for file_ in [os.path.join(base_dir, f) for f in files]: dir_name = os.path.dirname(file_) if not os.path.isdir(dir_name): os.makedirs(dir_name) with open(file_, 'w'): pass expected = list([ 'herringlib/f1.py', 'herringlib/f2.py', 'herringlib/f4/f5.py' ]) lib_path = Path(base_dir, 'herringlib') found = list(HerringLoader.library_files(library_paths=[lib_path])) self.assertEqual(sorted(found), sorted(expected)) finally: shutil.rmtree(base_dir)
def test_library_files_none(self): # noinspection PyArgumentEqualDefault self.assertEqual(len(list(HerringLoader.library_files(library_paths=None))), 0)