diff --git a/tests/fixtures.py b/tests/fixtures.py index 6c589b40..7a96dca6 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -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) diff --git a/tests/test_main.py b/tests/test_main.py index c7c39094..8225e2d1 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -3,6 +3,7 @@ import unittest import importlib import importlib_metadata +import itertools import pyfakefs.fake_filesystem_unittest as ffs from . import fixtures @@ -338,6 +339,17 @@ 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': { @@ -345,17 +357,12 @@ def test_packages_distributions_all_module_types(self): 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()