Coverage for src/zapy/test/test_case.py: 59%
15 statements
« prev ^ index » next coverage.py v7.4.1, created at 2024-02-10 19:35 +0000
« prev ^ index » next coverage.py v7.4.1, created at 2024-02-10 19:35 +0000
1import unittest
2import warnings
3from numbers import Real
5from httpx import Request, Response
8class TestCase(unittest.TestCase):
10 httpx_args: dict
11 request: Request
12 response: Response
14 def assert_between(self, x: Real, lo: Real, hi: Real) -> None:
15 """Verifies `lo <= x <= hi`.
16 Fails if `x` is not within the defined bounds.
18 Parameters
19 ----------
20 x : any
21 The value that should be within defined bounds.
23 lo : any
24 The lower bound, inclusive.
26 hi : any
27 The upper bound, inclusive.
29 Raises
30 ------
31 AssertionError
32 If `x` is not within the defined bounds.
33 """
34 if not (lo <= x <= hi):
35 err_msg = f"{x} not between {lo} and {hi}"
36 raise AssertionError(err_msg)
38 def assertBetween(self, x: Real, lo: Real, hi: Real) -> None: # noqa: N802
39 """This alias will be deprecated in preference of `assert_between`."""
40 warnings.warn("Call to deprecated function assertBetween. Replace it with assert_between.", stacklevel=2)
41 self.assert_between(x, lo, hi)