@@ -2433,6 +2433,30 @@ public void testCommentAtTheEnd() {
2433
2433
assertEquals (singletonList (requirement ), PyRequirementParser .fromText (name + " \\ \n --install-option=\" option\" # comment" ));
2434
2434
}
2435
2435
2436
+ // HASH OPTIONS
2437
+ // Test for parsing requirements with hash options
2438
+ public void testRequirementWithHash () {
2439
+ doTest ("certifi" , "2018.4.16" , "certifi==2018.4.16 --hash=sha256:13e698f54293db9f89122b0581843a782ad0934a4fe0172d2a980ba77fc61bb7" );
2440
+ doTest ("certifi" , "2018.4.16" ,
2441
+ "certifi==2018.4.16 --hash=sha256:13e698f54293db9f89122b0581843a782ad0934a4fe0172d2a980ba77fc61bb7 --hash=sha256:9fa520c1bacfb634fa7af20a76bcbd3d5fb390481724c597da32c719a7dca4b0" );
2442
+ }
2443
+
2444
+ // Test for parsing requirements with hash options from text (including line continuation)
2445
+ public void testRequirementWithHashFromText () {
2446
+ final List <PyRequirement > requirements = PyRequirementParser .fromText (
2447
+ "certifi==2018.4.16 \\ \n --hash=sha256:13e698f54293db9f89122b0581843a782ad0934a4fe0172d2a980ba77fc61bb7 \\ \n --hash=sha256:9fa520c1bacfb634fa7af20a76bcbd3d5fb390481724c597da32c719a7dca4b0" );
2448
+ assertFalse (requirements .isEmpty ());
2449
+
2450
+ final PyRequirement requirement = requirements .get (0 );
2451
+ assertNotNull (requirement );
2452
+ assertEquals ("certifi" , requirement .getName ());
2453
+ assertEquals ("2018.4.16" , requirement .getVersionSpecs ().get (0 ).getVersion ());
2454
+
2455
+ final List <String > installOptions = requirement .getInstallOptions ();
2456
+ assertTrue (installOptions .contains ("--hash=sha256:13e698f54293db9f89122b0581843a782ad0934a4fe0172d2a980ba77fc61bb7" ));
2457
+ assertTrue (installOptions .contains ("--hash=sha256:9fa520c1bacfb634fa7af20a76bcbd3d5fb390481724c597da32c719a7dca4b0" ));
2458
+ }
2459
+
2436
2460
// ENV MARKERS
2437
2461
// TODO: https://www.python.org/dev/peps/pep-0426/#environment-markers, https://www.python.org/dev/peps/pep-0508/#environment-markers
2438
2462
0 commit comments