Adjust coverage on vault tests for error-only code paths
Marco Ricci

Marco Ricci commited on 2025-01-29 15:36:12
Zeige 1 geänderte Dateien mit 4 Einfügungen und 4 Löschungen.


Code paths in the tests that only do error handling due to factors
beyond their control (here: unsatisfied hypothesis assumptions, or
re-raising the error) should not be counted towards coverage.
... ...
@@ -488,7 +488,7 @@ class TestVault:
488 488
             assert vault.Vault(phrase=phrase, **config).generate(
489 489
                 services[0]
490 490
             ) != vault.Vault(phrase=phrase, **config).generate(services[1])
491
-        except ValueError as exc:
491
+        except ValueError as exc:  # pragma: no cover
492 492
             # The service configuration strategy attempts to only
493 493
             # generate satisfiable configurations.  It is possible,
494 494
             # though rare, that this fails, and that unsatisfiability is
... ...
@@ -497,7 +497,7 @@ class TestVault:
497 497
             hypothesis.assume('no allowed characters left' not in exc.args)
498 498
             # Otherwise it's a genuine bug in the test case or the
499 499
             # implementation, and should be raised.
500
-            raise  # pragma: no cover
500
+            raise
501 501
 
502 502
     def test_210_nonstandard_length(self) -> None:
503 503
         """Deriving a passphrase adheres to imposed length limits."""
... ...
@@ -651,7 +651,7 @@ class TestVault:
651 651
         """Derived passphrases obey character and occurrence restraints."""
652 652
         try:
653 653
             password = vault.Vault(phrase=phrase, **config).generate(service)
654
-        except ValueError as exc:
654
+        except ValueError as exc:  # pragma: no cover
655 655
             # The service configuration strategy attempts to only
656 656
             # generate satisfiable configurations.  It is possible,
657 657
             # though rare, that this fails, and that unsatisfiability is
... ...
@@ -660,7 +660,7 @@ class TestVault:
660 660
             hypothesis.assume('no allowed characters left' not in exc.args)
661 661
             # Otherwise it's a genuine bug in the test case or the
662 662
             # implementation, and should be raised.
663
-            raise  # pragma: no cover
663
+            raise
664 664
         n = len(password)
665 665
         assert n == config['length'], 'Password has wrong length.'
666 666
         for key in ('lower', 'upper', 'number', 'space', 'dash', 'symbol'):
667 667