diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c1d4cec2..37d12dc1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,7 +1,7 @@ name: tests on: - push: +# push: pull_request: types: [opened, synchronize, reopened] @@ -13,8 +13,10 @@ jobs: strategy: fail-fast: false matrix: - os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.6', '3.7', '3.8', '3.9'] +# os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] +# python-version: ['3.6', '3.7', '3.8', '3.9'] + os: ['windows-latest'] + python-version: ['3.9'] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} diff --git a/tests/test_project.py b/tests/test_project.py index e1eca14e..899c0193 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -1,6 +1,7 @@ import os import subprocess -import shlex +from sys import platform +from venv import EnvBuilder def test_project_folder(cookies): @@ -13,23 +14,29 @@ def test_project_folder(cookies): def run(command: str, dirpath: os.PathLike) -> subprocess.CompletedProcess: - return subprocess.run(shlex.split(command), + print(command.split(' ')) + return subprocess.run(command.split(' '), stdout=subprocess.PIPE, stderr=subprocess.PIPE, - cwd=dirpath, - text=True) + cwd=dirpath, shell=True, + encoding='utf-8') -def test_pytest(cookies): +def test_pytest(cookies, tmp_path): result = cookies.bake() - env_output = run('python3 -m venv env', result.project) - assert env_output.returncode == 0 - latest_pip_output = run('env/bin/pip3 install --upgrade pip setuptools', result.project) + + # Programmatically do python3 -m venv env + env_root = str(tmp_path / 'env') + env_bin = f'{env_root}/Scripts/' if platform.startswith("win") else f'{env_root}/bin/' + builder = EnvBuilder(with_pip=True) + builder.create(env_root) + + latest_pip_output = run(f'{env_bin}pip3 install --upgrade pip setuptools', result.project) assert latest_pip_output.returncode == 0 - pip_output = run('env/bin/pip3 install --editable .[dev]', result.project) + pip_output = run(f'{env_bin}pip3 install --editable .[dev]', result.project) assert pip_output.returncode == 0 - pytest_output = run('env/bin/pytest', result.project) + pytest_output = run(f'{env_bin}pytest', result.project) assert pytest_output.returncode == 0 assert '== 3 passed in' in pytest_output.stdout assert (result.project / 'coverage.xml').exists()