def test_get_files(self): self.maxDiff = None self.assertEqual( sorted(get_source_files(BASE_DIR, '.py', True)), sorted([ os.path.join(BASE_DIR, 'definitions.py'), os.path.join(BASE_DIR, 'loc.py'), os.path.join(BASE_DIR, '__init__.py'), os.path.join(BASE_DIR, '__main__.py'), os.path.join(BASE_DIR, 'tests', 'test_loc.py'), os.path.join(BASE_DIR, 'tests', 'test_definitions.py'), os.path.join(BASE_DIR, 'tests', 'dummy_data', 'test.py'), os.path.join(BASE_DIR, 'tests', 'dummy_data', 'corner_case.py') ])) self.assertEqual( sorted( get_source_files(os.path.join( BASE_DIR, 'tests', ), '.py', True)), sorted([ os.path.join(BASE_DIR, 'tests', 'test_loc.py'), os.path.join(BASE_DIR, 'tests', 'test_definitions.py'), os.path.join(BASE_DIR, 'tests', 'dummy_data', 'test.py'), os.path.join(BASE_DIR, 'tests', 'dummy_data', 'corner_case.py') ]))
def test_non_existing_directory(): """Test with a directory that does not exist.""" result = get_source_files( source_dir="thisistotallyadirectorythatexistsyepsure", source_file_extensions=".py", ) assert result == []
def test_file_instead_of_directory(): """Test with a file instead of a directory.""" result = get_source_files( source_dir=os.path.join(BASE_DIR, "__init__.py"), source_file_extensions=".py", ) assert result == []
def test_get_files(): result = [ os.path.split(f)[-1] for f in get_source_files(BASE_DIR, ".py", True) ] expected = [ "definitions.py", "loc.py", "__init__.py", "__main__.py", ] assert sorted(result) == sorted(expected)