1111from . import helpers
1212
1313package_to_check = "xtensor"
14+ package_version_to_check = "0.27.0"
1415file_to_find_in_package = "xtensor.hpp"
1516
1617
18+ def package_to_check_requirements ():
19+ return f"{ package_to_check } ={ package_version_to_check } "
20+
21+
1722def find_cache_archive (cache : Path , pkg_name : str ) -> Optional [Path ]:
1823 """Find the archive used in cache from the complete build name."""
1924 tar_bz2 = cache / f"{ pkg_name } .tar.bz2"
@@ -46,7 +51,7 @@ def tmp_shared_cache_test_pkg(tmp_path_factory: pytest.TempPathFactory):
4651 "-c" ,
4752 "conda-forge" ,
4853 "--no-deps" ,
49- package_to_check ,
54+ package_to_check_requirements () ,
5055 no_dry_run = True ,
5156 )
5257 return root / "pkgs"
@@ -99,7 +104,7 @@ def test_extracted_file_deleted(
99104 os .remove (tmp_cache_file_in_test_package )
100105
101106 env_name = "some_env"
102- helpers .create (package_to_check , "-n" , env_name , no_dry_run = True )
107+ helpers .create (package_to_check_requirements () , "-n" , env_name , no_dry_run = True )
103108
104109 env_dir = tmp_root_prefix / "envs" / env_name
105110 pkg_checker = helpers .PackageChecker (package_to_check , env_dir )
@@ -122,7 +127,7 @@ def test_extracted_file_corrupted(
122127
123128 env_name = "x1"
124129 helpers .create (
125- package_to_check ,
130+ package_to_check_requirements () ,
126131 "-n" ,
127132 env_name ,
128133 "--json" ,
@@ -157,7 +162,7 @@ def test_tarball_deleted(
157162 os .remove (tmp_cache_test_pkg )
158163
159164 env_name = "x1"
160- helpers .create (package_to_check , "-n" , env_name , "--json" , no_dry_run = True )
165+ helpers .create (package_to_check_requirements () , "-n" , env_name , "--json" , no_dry_run = True )
161166
162167 env_dir = tmp_root_prefix / "envs" / env_name
163168 pkg_checker = helpers .PackageChecker (package_to_check , env_dir )
@@ -178,7 +183,7 @@ def test_tarball_and_extracted_file_deleted(
178183 os .remove (tmp_cache_test_pkg )
179184
180185 env_name = "x1"
181- helpers .create (package_to_check , "-n" , env_name , "--json" , no_dry_run = True )
186+ helpers .create (package_to_check_requirements () , "-n" , env_name , "--json" , no_dry_run = True )
182187
183188 env_dir = tmp_root_prefix / "envs" / env_name
184189 pkg_checker = helpers .PackageChecker (package_to_check , env_dir )
@@ -203,7 +208,7 @@ def test_tarball_corrupted_and_extracted_file_deleted(
203208 f .write ("" )
204209
205210 env_name = "x1"
206- helpers .create (package_to_check , "-n" , env_name , "--json" , no_dry_run = True )
211+ helpers .create (package_to_check_requirements () , "-n" , env_name , "--json" , no_dry_run = True )
207212
208213 env_dir = tmp_root_prefix / "envs" / env_name
209214 pkg_checker = helpers .PackageChecker (package_to_check , env_dir )
@@ -233,7 +238,7 @@ def test_extracted_file_corrupted_no_perm(
233238
234239 env = "x1"
235240 cmd_args = (
236- package_to_check ,
241+ package_to_check_requirements () ,
237242 "-n" ,
238243 "--safety-checks" ,
239244 safety_checks ,
@@ -276,7 +281,9 @@ def test_different_caches(
276281
277282 os .environ ["CONDA_PKGS_DIRS" ] = f"{ cache } "
278283 env_name = "some_env"
279- res = helpers .create ("-n" , env_name , package_to_check , "-v" , "--json" , no_dry_run = True )
284+ res = helpers .create (
285+ "-n" , env_name , package_to_check_requirements (), "-v" , "--json" , no_dry_run = True
286+ )
280287
281288 env_dir = tmp_root_prefix / "envs" / env_name
282289 pkg_checker = helpers .PackageChecker (package_to_check , env_dir )
@@ -304,7 +311,9 @@ def test_first_writable(
304311 os .environ ["CONDA_PKGS_DIRS" ] = f"{ tmp_cache } ,{ tmp_cache_alt } "
305312
306313 env_name = "some_env"
307- res = helpers .create ("-n" , env_name , package_to_check , "--json" , no_dry_run = True )
314+ res = helpers .create (
315+ "-n" , env_name , package_to_check_requirements (), "--json" , no_dry_run = True
316+ )
308317
309318 env_dir = tmp_root_prefix / "envs" / env_name
310319 pkg_checker = helpers .PackageChecker (package_to_check , env_dir )
@@ -330,7 +339,7 @@ def test_no_writable(self, tmp_home, tmp_root_prefix, tmp_cache, tmp_cache_alt):
330339
331340 os .environ ["CONDA_PKGS_DIRS" ] = f"{ tmp_cache } ,{ tmp_cache_alt } "
332341
333- helpers .create ("-n" , "myenv" , package_to_check , "--json" , no_dry_run = True )
342+ helpers .create ("-n" , "myenv" , package_to_check_requirements () , "--json" , no_dry_run = True )
334343
335344 def test_no_writable_extracted_dir_corrupted (self , tmp_home , tmp_root_prefix , tmp_cache ):
336345 old_cache_dir = tmp_cache / find_pkg_build (tmp_cache , package_to_check )
@@ -345,7 +354,9 @@ def test_no_writable_extracted_dir_corrupted(self, tmp_home, tmp_root_prefix, tm
345354 os .environ ["CONDA_PKGS_DIRS" ] = f"{ tmp_cache } "
346355
347356 with pytest .raises (subprocess .CalledProcessError ):
348- helpers .create ("-n" , "myenv" , package_to_check , "-vv" , "--json" , no_dry_run = True )
357+ helpers .create (
358+ "-n" , "myenv" , package_to_check_requirements (), "-vv" , "--json" , no_dry_run = True
359+ )
349360
350361 def test_first_writable_extracted_dir_corrupted (
351362 self , tmp_home , tmp_root_prefix , tmp_cache , tmp_cache_alt
@@ -365,7 +376,9 @@ def test_first_writable_extracted_dir_corrupted(
365376 os .environ ["CONDA_PKGS_DIRS" ] = f"{ tmp_cache } ,{ tmp_cache_alt } "
366377 env_name = "myenv"
367378
368- helpers .create ("-n" , env_name , package_to_check , "-vv" , "--json" , no_dry_run = True )
379+ helpers .create (
380+ "-n" , env_name , package_to_check_requirements (), "-vv" , "--json" , no_dry_run = True
381+ )
369382
370383 install_env_dir = helpers .get_env (env_name )
371384 pkg_checker = helpers .PackageChecker (package_to_check , install_env_dir )
@@ -410,7 +423,7 @@ def test_extracted_tarball_only_in_non_writable_cache(
410423 os .environ ["CONDA_PKGS_DIRS" ] = f"{ tmp_cache } ,{ tmp_cache_alt } "
411424 env_name = "myenv"
412425
413- helpers .create ("-n" , env_name , package_to_check , "--json" , no_dry_run = True )
426+ helpers .create ("-n" , env_name , package_to_check_requirements () , "--json" , no_dry_run = True )
414427
415428 install_env_dir = helpers .get_env (env_name )
416429 pkg_checker = helpers .PackageChecker (package_to_check , install_env_dir )
@@ -450,7 +463,7 @@ def test_missing_extracted_dir_in_non_writable_cache(
450463 os .environ ["CONDA_PKGS_DIRS" ] = f"{ tmp_cache } ,{ tmp_cache_alt } "
451464 env_name = "myenv"
452465
453- helpers .create ("-n" , env_name , package_to_check , "--json" , no_dry_run = True )
466+ helpers .create ("-n" , env_name , package_to_check_requirements () , "--json" , no_dry_run = True )
454467
455468 install_env_dir = helpers .get_env (env_name )
456469 pkg_checker = helpers .PackageChecker (package_to_check , install_env_dir )
@@ -496,7 +509,9 @@ def test_corrupted_extracted_dir_in_non_writable_cache(
496509 os .environ ["CONDA_PKGS_DIRS" ] = f"{ tmp_cache } ,{ tmp_cache_alt } "
497510 env_name = "myenv"
498511
499- helpers .create ("-n" , env_name , "-vv" , package_to_check , "--json" , no_dry_run = True )
512+ helpers .create (
513+ "-n" , env_name , "-vv" , package_to_check_requirements (), "--json" , no_dry_run = True
514+ )
500515
501516 install_env_dir = helpers .get_env (env_name )
502517 pkg_checker = helpers .PackageChecker (package_to_check , install_env_dir )
@@ -542,7 +557,7 @@ def test_expired_but_valid_repodata_in_non_writable_cache(
542557 helpers .create (
543558 "-n" ,
544559 env_name ,
545- package_to_check ,
560+ package_to_check_requirements () ,
546561 "-vv" ,
547562 "--json" ,
548563 "--repodata-ttl=0" ,
0 commit comments