Skip to content

Commit c035cee

Browse files
committed
Merge remote-tracking branch 'origin/main' into 160-subpackage
2 parents 9a0fab4 + 7e9b9ac commit c035cee

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

tests/test_project.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import subprocess
3-
import shlex
3+
from sys import platform
4+
from typing import Sequence
45

56
import pytest
67

@@ -14,8 +15,8 @@ def test_project_folder(cookies):
1415
assert project.project.isdir()
1516

1617

17-
def run(command: str, dirpath: os.PathLike) -> subprocess.CompletedProcess:
18-
return subprocess.run(shlex.split(command),
18+
def run(args: Sequence[str], dirpath: os.PathLike) -> subprocess.CompletedProcess:
19+
return subprocess.run(args=args,
1920
stdout=subprocess.PIPE,
2021
stderr=subprocess.PIPE,
2122
cwd=dirpath,
@@ -25,26 +26,27 @@ def run(command: str, dirpath: os.PathLike) -> subprocess.CompletedProcess:
2526
@pytest.fixture
2627
def baked_withdevdeps(cookies):
2728
result = cookies.bake()
28-
env_output = run('python3 -m venv env', result.project)
29+
env_output = run(['python3', '-m', 'venv', 'env'], result.project)
2930
assert env_output.returncode == 0
30-
latest_pip_output = run('env/bin/pip3 install --upgrade pip setuptools', result.project)
31+
env_bin = 'env/Scripts/' if platform.startswith("win") else 'env/bin/'
32+
latest_pip_output = run([f'{env_bin}pip3', 'install', '--upgrade', 'pip', 'setuptools'], result.project)
3133
assert latest_pip_output.returncode == 0
32-
pip_output = run('env/bin/pip3 install --editable .[dev]', result.project)
34+
pip_output = run([f'{env_bin}pip3', 'install', '--editable', '.[dev]'], result.project)
3335
assert pip_output.returncode == 0
34-
return result.project
36+
return result.project, env_bin
3537

3638

3739
def test_pytest(baked_withdevdeps):
38-
project_dir = baked_withdevdeps
39-
pytest_output = run('env/bin/pytest', project_dir)
40+
project_dir, env_bin = baked_withdevdeps
41+
pytest_output = run([f'{env_bin}pytest'], result.project)
4042
assert pytest_output.returncode == 0
4143
assert '== 3 passed in' in pytest_output.stdout
4244
assert (project_dir / 'coverage.xml').exists()
4345
assert (project_dir / 'htmlcov/index.html').exists()
4446

4547

4648
def test_subpackage(baked_withdevdeps):
47-
project_dir = baked_withdevdeps
49+
project_dir, env_bin = baked_withdevdeps
4850
subpackage = (project_dir / 'my_python_package' / 'mysub')
4951
subpackage.mkdir()
5052
(subpackage / '__init__.py').write_text('FOO = "bar"', encoding="utf-8")
@@ -53,7 +55,7 @@ def test_subpackage(baked_withdevdeps):
5355
subsubpackage.mkdir()
5456
(subsubpackage / '__init__.py').write_text('FOO = "bar"', encoding="utf-8")
5557

56-
build_output = run('env/bin/python3 setup.py build', project_dir)
58+
build_output = run('f'{env_bin}python3 setup.py build', project_dir)
5759
assert build_output.returncode == 0
5860
assert (project_dir / 'build' / 'lib' / 'my_python_package' / 'mysub' / '__init__.py').exists()
5961
assert (project_dir / 'build' / 'lib' / 'my_python_package' / 'mysub' / 'mysub2' / '__init__.py').exists()

0 commit comments

Comments
 (0)