Skip to content

Commit 33046cd

Browse files
committed
Add test to check subpackage is included in build
1 parent 44feb3b commit 33046cd

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

tests/test_project.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import subprocess
33
import shlex
44

5+
import pytest
6+
57

68
def test_project_folder(cookies):
79
project = cookies.bake()
@@ -20,17 +22,32 @@ def run(command: str, dirpath: os.PathLike) -> subprocess.CompletedProcess:
2022
encoding="utf-8")
2123

2224

23-
def test_pytest(cookies):
25+
@pytest.fixture
26+
def baked_withdevdeps(cookies):
2427
result = cookies.bake()
2528
env_output = run('python3 -m venv env', result.project)
2629
assert env_output.returncode == 0
2730
latest_pip_output = run('env/bin/pip3 install --upgrade pip setuptools', result.project)
2831
assert latest_pip_output.returncode == 0
2932
pip_output = run('env/bin/pip3 install --editable .[dev]', result.project)
3033
assert pip_output.returncode == 0
34+
return result.project
35+
3136

32-
pytest_output = run('env/bin/pytest', result.project)
37+
def test_pytest(baked_withdevdeps):
38+
project_dir = baked_withdevdeps
39+
pytest_output = run('env/bin/pytest', project_dir)
3340
assert pytest_output.returncode == 0
34-
assert '== 3 passed in' in pytest_output.stdout
35-
assert (result.project / 'coverage.xml').exists()
36-
assert (result.project / 'htmlcov/index.html').exists()
41+
assert '== 3 passed in' in pytest_output.stdout
42+
assert (project_dir / 'coverage.xml').exists()
43+
assert (project_dir / 'htmlcov/index.html').exists()
44+
45+
46+
def test_subpackage(baked_withdevdeps):
47+
project_dir = baked_withdevdeps
48+
subpackage = (project_dir / 'my_python_package' / 'mysub')
49+
subpackage.mkdir()
50+
(subpackage / '__init__.py').write_text('FOO = "bar"', encoding="utf-8")
51+
build_output = run('python3 setup.py build', project_dir)
52+
assert build_output.returncode == 0
53+
assert (project_dir / 'build' / 'lib' / 'my_python_package' / 'mysub' / '__init__.py').exists()

0 commit comments

Comments
 (0)