Skip to content

Commit

Permalink
test_packages_distributions_all_module_types() must create existing f…
Browse files Browse the repository at this point in the history
…iles for all the entries in RECORD
  • Loading branch information
jherland committed Mar 19, 2023
1 parent 33eb7b4 commit fa9cca4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ def build_files(file_defs, prefix=pathlib.Path()):
full_name.mkdir()
build_files(contents, prefix=full_name)
else:
full_name.parent.mkdir(parents=True, exist_ok=True)
if isinstance(contents, bytes):
with full_name.open('wb') as f:
f.write(contents)
Expand Down
21 changes: 14 additions & 7 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import unittest
import importlib
import importlib_metadata
import itertools
import pyfakefs.fake_filesystem_unittest as ffs

from . import fixtures
Expand Down Expand Up @@ -338,24 +339,30 @@ def test_packages_distributions_all_module_types(self):
Test top-level modules detected on a package without 'top-level.txt'.
"""
suffixes = importlib.machinery.all_suffixes()
filenames = list(
itertools.chain.from_iterable(
[
f'{i}-top-level{suffix}',
f'{i}-in-namespace/mod{suffix}',
f'{i}-in-package/__init__.py',
f'{i}-in-package/mod{suffix}',
]
for i, suffix in enumerate(suffixes)
)
)
fixtures.build_files(
{
'all_distributions-1.0.0.dist-info': {
'METADATA': """
Name: all_distributions
Version: 1.0.0
""",
'RECORD': ''.join(
f'{i}-top-level{suffix},,\n'
f'{i}-in-namespace/mod{suffix},,\n'
f'{i}-in-package/__init__.py,,\n'
f'{i}-in-package/mod{suffix},,\n'
for i, suffix in enumerate(suffixes)
),
'RECORD': ''.join(f'{fname},,\n' for fname in filenames),
},
},
prefix=self.site_dir,
)
fixtures.build_files({fname: "" for fname in filenames}, prefix=self.site_dir)

distributions = packages_distributions()

Expand Down

0 comments on commit fa9cca4

Please sign in to comment.