Skip to content

Commit

Permalink
test: list actual files in test dir
Browse files Browse the repository at this point in the history
  • Loading branch information
mawillcockson committed Sep 30, 2021
1 parent 9335bfb commit 3d5df53
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@
LIST_FILES_TEMPLATE = """\
#!{python}
import sys
from os.path import join
if '--deleted' not in sys.argv:
files = ['pyproject.toml', '{module}', 'EG_README.rst']
print('\\0'.join(files), end='\\0')
from pathlib import Path
cwd = Path.cwd()
git_dir = (cwd / ".git")
for path in cwd.rglob("*"):
if git_dir in path.parents or path in [cwd, git_dir] or not path.is_file():
continue
print(str(path.relative_to(cwd)), end="\\0")
"""

def test_build_main(copy_sample):
td = copy_sample('module1_toml')
(td / '.git').mkdir() # Fake a git repo

with MockCommand('git', LIST_FILES_TEMPLATE.format(
python=sys.executable, module='module1.py')):
python=sys.executable)):
res = build.main(td / 'pyproject.toml')
assert res.wheel.file.suffix == '.whl'
assert res.sdist.file.name.endswith('.tar.gz')
Expand All @@ -36,7 +40,7 @@ def test_build_sdist_only(copy_sample):
(td / '.git').mkdir() # Fake a git repo

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

Expand All @@ -48,7 +52,7 @@ def test_build_wheel_only(copy_sample):
(td / '.git').mkdir() # Fake a git repo

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

Expand All @@ -65,7 +69,7 @@ def test_build_module_no_docstring():


with MockCommand('git', LIST_FILES_TEMPLATE.format(
python=sys.executable, module='no_docstring.py')):
python=sys.executable)):
with pytest.raises(common.NoDocstringError) as exc_info:
build.main(pyproject)
assert 'no_docstring.py' in str(exc_info.value)

0 comments on commit 3d5df53

Please sign in to comment.