@@ -715,17 +715,14 @@ def test_magic(self):
715715 py_version = "3.11"
716716 message = self .MAGIC .format (1234 , 3495 )
717717
718- run = self .RunGradle ("base" , "Pyc/magic_warning" , run = False )
718+ run = self .RunGradle ("base" , run = False )
719719 command = make_venv (f"{ run .project_dir } /app/venv" , py_version )
720720 kwargs = dict (
721- env = {
722- "python_version" : py_version ,
723- "buildpython" : command ,
724- "PYTHONPATH" : "pythonpath" ,
725- },
721+ context = {"pythonVersion" : py_version , "buildPython" : command },
722+ env = {"PYTHONPATH" : "pythonpath" },
726723 python_version = py_version , app = ["hello.py" ], pyc = ["stdlib" ],
727724 )
728- run .rerun (** kwargs )
725+ run .rerun ("Pyc/magic_warning" , ** kwargs )
729726 self .assertInStdout (
730727 WARNING + re .escape (self .FAILED + message + self .SEE ), run , re = True )
731728
@@ -816,7 +813,7 @@ def run_override(self, run, command, *, error=None, executable=None, **kwargs):
816813
817814 run .rerun (
818815 "BuildPython/override" ,
819- context = {"buildpython " : "----" .join (command )},
816+ context = {"buildPython " : "----" .join (command )},
820817 ** kwargs ,
821818 )
822819 if error :
@@ -981,7 +978,7 @@ def test_python_version(self):
981978 for version in [MIN_PYTHON_VERSION , MAX_PYTHON_VERSION ]:
982979 with self .subTest (version = version ):
983980 self .RunGradle ("base" , "PythonReqs/python_version" ,
984- env = {"python_version " : version },
981+ context = {"pythonVersion " : version },
985982 python_version = version ,
986983 requirements = ["apple/__init__.py" ,
987984 "no_binary_sdist/__init__.py" ,
@@ -1044,17 +1041,24 @@ def test_download_sdist(self):
10441041 # Linux because conda uses RPATH on that platform, and I think it's similar on Mac.
10451042 @skipUnless (os .name == "nt" , "Windows only" )
10461043 def test_conda (self ):
1047- # Remove PATH entries which contain any copy of libssl. If it's installed in
1048- # C:\Windows\System32 or some other critical directory, then this test will probably
1049- # fail.
1044+ kwargs = dict (
1045+ context = {
1046+ "buildPython" : join (product_props ["chaquopy.conda.env" ], "python.exe" )
1047+ },
1048+ requirements = ["six.py" ], pyc = ["stdlib" ],
1049+ )
1050+
1051+ # Remove PATH entries which contain any copy of libssl. If this removes
1052+ # C:\Windows\System32 or some other critical directory, then this test will
1053+ # probably fail.
10501054 path = os .pathsep .join (
10511055 entry for entry in os .environ ["PATH" ].split (os .pathsep )
10521056 if isdir (entry ) and not any (fnmatch (filename , "libssl*.dll" )
10531057 for filename in os .listdir (entry )))
1054- self . RunGradle ( "base" , "PythonReqs/conda" ,
1055- env = { "chaquopy_conda_env " : product_props [ "chaquopy.conda.env" ],
1056- "PATH" : path },
1057- requirements = [ "six.py" ], pyc = [ "stdlib" ] )
1058+ if path != os . environ [ "PATH" ]:
1059+ kwargs [ " env" ] = { "PATH " : path }
1060+
1061+ self . RunGradle ( "base" , "PythonReqs/conda" , ** kwargs )
10581062
10591063 ISOLATED_KWARGS = dict (
10601064 dist_versions = [("six" , "1.14.0" ), ("build_requires_six" , "1.14.0" )],
@@ -1314,8 +1318,7 @@ def test_sdist_site(self):
13141318 PKG_NAME = "javaproperties"
13151319 run_build_python (["-c" , f"import { PKG_NAME } " ])
13161320
1317- run = self .RunGradle ("base" , "PythonReqs/sdist_site" ,
1318- env = {"CHAQUOPY_PKG_NAME" : PKG_NAME }, succeed = False )
1321+ run = self .RunGradle ("base" , "PythonReqs/sdist_site" , succeed = False )
13191322 self .assertInLong (f"No module named '{ PKG_NAME } '" , run .stderr )
13201323
13211324 def test_editable (self ):
@@ -1647,7 +1650,7 @@ def test_python_version(self):
16471650 for version in [MIN_PYTHON_VERSION , MAX_PYTHON_VERSION ]:
16481651 with self .subTest (version = version ):
16491652 self .RunGradle ("base" , "StaticProxy/python_version" ,
1650- env = {"python_version " : version },
1653+ context = {"pythonVersion " : version },
16511654 python_version = version ,
16521655 app = ["chaquopy_test/__init__.py" , "chaquopy_test/a.py" ],
16531656 classes = {"chaquopy_test.a" : ["SrcA1" ]},
@@ -1693,7 +1696,7 @@ class RunGradle(object):
16931696 MAX_RUNS_PER_DAEMON = 100
16941697 runs_per_daemon = 0
16951698
1696- def __init__ (self , test , * layers , run = True , ** kwargs ):
1699+ def __init__ (self , test , * layers , context = None , run = True , ** kwargs ):
16971700 self .test = test
16981701 if os .path .exists (test .run_dir ):
16991702 rmtree (test .run_dir )
@@ -1707,7 +1710,7 @@ def __init__(self, test, *layers, run=True, **kwargs):
17071710
17081711 self .project_dir = join (test .run_dir , "project" )
17091712 os .makedirs (self .project_dir )
1710- self .apply_layers (* layers )
1713+ self .apply_layers (* layers , context = context )
17111714 if run :
17121715 self .rerun (** kwargs )
17131716
@@ -1824,9 +1827,6 @@ def run_gradle(self, variants, env, java_version):
18241827 # daemon (https://github.com/gradle/gradle/issues/12905). On the other
18251828 # platforms, this only affects specific variables such as PATH and TZ
18261829 # (https://github.com/gradle/gradle/issues/10483).
1827- #
1828- # TODO: avoid this by using `properties` instead wherever possible. This
1829- # will also make it easier to rerun failed tests manually.
18301830 gradlew_flags .append ("--no-daemon" )
18311831
18321832 # The following environment variables aren't affected by the above issue, either
0 commit comments