11import os
22import subprocess
3- from pathlib import Path
4- from shutil import which
53from sys import platform
64from typing import Sequence
75
86import pytest
97
108IS_WINDOWS = platform .startswith ('win' )
11- IS_WINDOWS_CI = IS_WINDOWS and os .environ .get ('CI' , False )
129
1310
1411def test_project_folder (cookies ):
@@ -33,17 +30,11 @@ def run(args: Sequence[str], dirpath: os.PathLike) -> subprocess.CompletedProces
3330
3431@pytest .fixture
3532def project_env_bin_dir (tmp_path ):
36- if IS_WINDOWS_CI :
37- # Creating virtualenv does not work on Windows CI,
38- # falling back to using current pip3 dir
39- pip = Path (which ('pip3' ))
40- bin_dir = pip .parent
41- else :
42- env_output = run (['python3' , '-m' , 'venv' , 'env' ], tmp_path )
43- assert env_output .returncode == 0
44- bin_dir = str (tmp_path / 'env' / 'bin' )
45- if IS_WINDOWS :
46- bin_dir = str (tmp_path / 'env' / 'Scripts' )
33+ env_output = run (['python' , '-m' , 'venv' , 'env' ], tmp_path )
34+ assert env_output .returncode == 0
35+ bin_dir = str (tmp_path / 'env' / 'bin' )
36+ if IS_WINDOWS :
37+ bin_dir = str (tmp_path / 'env' / 'Scripts' )
4738 return str (bin_dir ) + os .sep
4839
4940
@@ -52,17 +43,17 @@ def baked_with_development_dependencies(cookies, project_env_bin_dir):
5243 result = cookies .bake ()
5344 assert result .exit_code == 0
5445 bin_dir = project_env_bin_dir
55- latest_pip_output = run ([f'{ bin_dir } pip3 ' , 'install' , '--upgrade' , 'pip' , 'setuptools' ], result .project )
46+ latest_pip_output = run ([f'{ bin_dir } python' , '-m' , 'pip ' , 'install' , '--upgrade' , 'pip' , 'setuptools' ], result .project )
5647 assert latest_pip_output .returncode == 0
57- pip_output = run ([f'{ bin_dir } pip3 ' , 'install' , '--editable' , '.[dev]' ], result .project )
48+ pip_output = run ([f'{ bin_dir } python' , '-m' , 'pip ' , 'install' , '--editable' , '.[dev]' ], result .project )
5849 assert pip_output .returncode == 0
5950 return result .project
6051
6152
6253def test_pytest (baked_with_development_dependencies , project_env_bin_dir ):
6354 project_dir = baked_with_development_dependencies
6455 bin_dir = project_env_bin_dir
65- result = run ([f'{ bin_dir } pytest' ], project_dir )
56+ result = run ([f'{ bin_dir } python' , '-m' , ' pytest' ], project_dir )
6657 assert result .returncode == 0
6758 assert '== 3 passed in' in result .stdout
6859
@@ -98,9 +89,6 @@ def test_subpackage(baked_with_development_dependencies, project_env_bin_dir):
9889 subsubpackage .mkdir ()
9990 (subsubpackage / '__init__.py' ).write_text ('FOO = "bar"' , encoding = "utf-8" )
10091
101- if IS_WINDOWS_CI :
102- # On Windows CI python and pip executable are in different paths
103- bin_dir = ''
10492 # sdist and bdist_wheel both call build command to create build/ dir
10593 # So instead of looking in distribution archives we can look in build/ dir
10694 result = run ([f'{ bin_dir } python' , 'setup.py' , 'build' ], project_dir )
0 commit comments