Skip to content

Commit

Permalink
Relax assertion that all names in packages_distributions are identifi…
Browse files Browse the repository at this point in the history
…ers.

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'.
  • Loading branch information
jaraco committed Apr 9, 2023
1 parent 340cac3 commit a4e2a9b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/test_main.py
Expand Up @@ -354,7 +354,9 @@ def test_packages_distributions_all_module_types(self):
assert distributions[f'in_namespace_{i}'] == ['all_distributions']
assert distributions[f'in_package_{i}'] == ['all_distributions']

# All keys return from packages_distributions() should be valid
# import names, which means that they must _at least_ be valid
# identifiers:
assert all(import_name.isidentifier() for import_name in distributions.keys())
def is_importable(name):
return '.' not in name

# All keys returned from packages_distributions() should be
# importable.
assert all(map(is_importable, distributions))

0 comments on commit a4e2a9b

Please sign in to comment.