@@ -311,3 +311,64 @@ def test_new_resolver_hash_requirement_and_url_constraint_can_fail(
311311 ) in result .stderr , str (result )
312312
313313 script .assert_not_installed ("base" , "other" )
314+
315+
316+ def test_new_resolver_hash_with_extras (script : PipTestEnvironment ) -> None :
317+ parent_with_extra_path = create_basic_wheel_for_package (
318+ script , "parent_with_extra" , "0.1.0" , depends = ["child[extra]" ]
319+ )
320+ parent_with_extra_hash = hashlib .sha256 (
321+ parent_with_extra_path .read_bytes ()
322+ ).hexdigest ()
323+
324+ parent_without_extra_path = create_basic_wheel_for_package (
325+ script , "parent_without_extra" , "0.1.0" , depends = ["child" ]
326+ )
327+ parent_without_extra_hash = hashlib .sha256 (
328+ parent_without_extra_path .read_bytes ()
329+ ).hexdigest ()
330+
331+ child_path = create_basic_wheel_for_package (
332+ script , "child" , "0.1.0" , extras = {"extra" : ["extra" ]}
333+ )
334+ child_hash = hashlib .sha256 (child_path .read_bytes ()).hexdigest ()
335+
336+ # Newer release
337+ create_basic_wheel_for_package (
338+ script , "child" , "0.2.0" , extras = {"extra" : ["extra" ]}
339+ )
340+
341+ extra_path = create_basic_wheel_for_package (script , "extra" , "0.1.0" )
342+ extra_hash = hashlib .sha256 (extra_path .read_bytes ()).hexdigest ()
343+
344+ requirements_txt = script .scratch_path / "requirements.txt"
345+ requirements_txt .write_text (
346+ """
347+ child[extra]==0.1.0 --hash=sha256:{child_hash}
348+ parent_with_extra==0.1.0 --hash=sha256:{parent_with_extra_hash}
349+ parent_without_extra==0.1.0 --hash=sha256:{parent_without_extra_hash}
350+ extra==0.1.0 --hash=sha256:{extra_hash}
351+ """ .format (
352+ child_hash = child_hash ,
353+ parent_with_extra_hash = parent_with_extra_hash ,
354+ parent_without_extra_hash = parent_without_extra_hash ,
355+ extra_hash = extra_hash ,
356+ ),
357+ )
358+
359+ script .pip (
360+ "install" ,
361+ "--no-cache-dir" ,
362+ "--no-index" ,
363+ "--find-links" ,
364+ script .scratch_path ,
365+ "--requirement" ,
366+ requirements_txt ,
367+ )
368+
369+ script .assert_installed (
370+ parent_with_extra = "0.1.0" ,
371+ parent_without_extra = "0.1.0" ,
372+ child = "0.1.0" ,
373+ extra = "0.1.0" ,
374+ )
0 commit comments