Skip to content

Commit

Permalink
test: remove per-test module folder listing
Browse files Browse the repository at this point in the history
keep explicit tracked files listing

remove unneeded import from git mock script template
  • Loading branch information
mawillcockson committed Nov 30, 2021
1 parent 542f600 commit c1be8f8
Showing 1 changed file with 5 additions and 34 deletions.
39 changes: 5 additions & 34 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,16 @@
if '--deleted' not in sys.argv:
for filename in tracked:
print(filename, end="\\0")
else:
from pathlib import Path, PurePosixPath
cwd = Path.cwd()
git_dir = cwd / ".git"
tracked = [(cwd / filename) for filename in tracked]
for path in cwd.rglob("*"):
if (
not path.is_file()
or path in tracked
or git_dir in path.parents
or path in [cwd, git_dir]
):
continue
relative_path = path.relative_to(cwd)
linux_path = PurePosixPath().joinpath(*relative_path.parts)
print(str(linux_path), end="\\0")
"""

MODULE1_TOML_FILES = ["EG_README.rst", "module1.py", "pyproject.toml"]

def test_build_main(copy_sample):
td = copy_sample('module1_toml')
(td / '.git').mkdir() # Fake a git repo
tracked = [
str(path.relative_to(samples_dir / "module1_toml"))
for path in (samples_dir / "module1_toml").rglob("*")
if path.is_file()
]

with MockCommand('git', LIST_FILES_TEMPLATE.format(
python=sys.executable, tracked=tracked)):
python=sys.executable, tracked=MODULE1_TOML_FILES)):
res = build.main(td / 'pyproject.toml')
assert res.wheel.file.suffix == '.whl'
assert res.sdist.file.name.endswith('.tar.gz')
Expand All @@ -55,14 +36,9 @@ def test_build_main(copy_sample):
def test_build_sdist_only(copy_sample):
td = copy_sample('module1_toml')
(td / '.git').mkdir() # Fake a git repo
tracked = [
str(path.relative_to(samples_dir / "module1_toml"))
for path in (samples_dir / "module1_toml").rglob("*")
if path.is_file()
]

with MockCommand('git', LIST_FILES_TEMPLATE.format(
python=sys.executable, tracked=tracked)):
python=sys.executable, tracked=MODULE1_TOML_FILES)):
res = build.main(td / 'pyproject.toml', formats={'sdist'})
assert res.wheel is None

Expand All @@ -72,14 +48,9 @@ def test_build_sdist_only(copy_sample):
def test_build_wheel_only(copy_sample):
td = copy_sample('module1_toml')
(td / '.git').mkdir() # Fake a git repo
tracked = [
str(path.relative_to(samples_dir / "module1_toml"))
for path in (samples_dir / "module1_toml").rglob("*")
if path.is_file()
]

with MockCommand('git', LIST_FILES_TEMPLATE.format(
python=sys.executable, tracked=tracked)):
python=sys.executable, tracked=MODULE1_TOML_FILES)):
res = build.main(td / 'pyproject.toml', formats={'wheel'})
assert res.sdist is None

Expand Down

0 comments on commit c1be8f8

Please sign in to comment.