def test_get_mods_no_dupes(listdir): """ Listing modules does not return duplicates """ listdir.return_value = ['01_01_test.py', '01_01_test.pyc', '01_02_test.py'] mocked_pkg = mock.Mock() mocked_pkg.__path__ = ['foo'] m = mod.get_mods(mocked_pkg) assert m == [('01_01_test', 1, 1), ('01_02_test', 1, 2)]
def test_get_mods_ignores_non_migration_files(listdir): """ Listing modules will not return modules aren't migrations """ listdir.return_value = ['__init__.py', 'foo.py', '01_01_test.py', '01_02_test.py'] mocked_pkg = mock.Mock() mocked_pkg.__path__ = ['foo'] m = mod.get_mods(mocked_pkg) assert m == [('01_01_test', 1, 1), ('01_02_test', 1, 2)]