Skip to content

Commit a4e2a9b

Browse files
committed
Relax assertion that all names in packages_distributions are identifiers.
The main contstraint here for an importable module is that it must not contain a module separator ('.'). Other names that contain dashes or spaces cannot be imported with the 'import' statement, but can be imported with 'importlib.import_module' or invoked with 'runpy'.
1 parent 340cac3 commit a4e2a9b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/test_main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,9 @@ def test_packages_distributions_all_module_types(self):
354354
assert distributions[f'in_namespace_{i}'] == ['all_distributions']
355355
assert distributions[f'in_package_{i}'] == ['all_distributions']
356356

357-
# All keys return from packages_distributions() should be valid
358-
# import names, which means that they must _at least_ be valid
359-
# identifiers:
360-
assert all(import_name.isidentifier() for import_name in distributions.keys())
357+
def is_importable(name):
358+
return '.' not in name
359+
360+
# All keys returned from packages_distributions() should be
361+
# importable.
362+
assert all(map(is_importable, distributions))

0 commit comments

Comments
 (0)