Skip to content

Commit b742b6b

Browse files
committed
[IMP] src/testing: improve docs
Fix some RST syntax issues in parametrize docs. Take the opportunity to improve its docstring. Clarify IntegrityCase. closes #341 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent 17f5462 commit b742b6b

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/testing.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,22 @@ def parametrize(argvalues):
150150
Parametrize a test function.
151151
152152
Decorator for upgrade test functions to parametrize and generate multiple tests from
153-
it.
153+
it. The new test functions are injected in the containing class. Inspired by the
154+
`parameterized <https://pypi.org/project/parameterized/>`_ package.
154155
155-
Usage::
156+
.. example::
157+
158+
.. code-block:: python
156159
157-
@parametrize([(1, 2), (2, 4), (-1, -2), (0, 0)])
158-
def test_double(self, input, expected):
159-
self.assertEqual(input * 2, expected)
160+
@parametrize([(1, 2), (2, 4), (-1, -2), (0, 0)])
161+
def test_double(self, input, expected):
162+
self.assertEqual(input * 2, expected)
160163
161-
Works by injecting test functions in the containing class.
162-
Inspired by the `parameterized <https://pypi.org/project/parameterized/>`_ package.
164+
This will generate four test methods: ``test_double__0``, ``test_double__1``,
165+
``test_double__2``, and ``test_double__3``, each with different argument values.
166+
167+
:param list(tuple) argvalues: Arguments for each test case. Each tuple will be
168+
unpacked and passed as arguments to the test function.
163169
"""
164170

165171
def make_func(func, name, args):
@@ -521,7 +527,7 @@ def get_previous_major(major, minor):
521527
# pylint: disable=inherit-non-class
522528
class UpgradeCase(UpgradeCommon, _create_meta(10, "upgrade_case")):
523529
"""
524-
Test case to verify that the upgrade scripts correctly upgrade data.
530+
Test case to verify the upgrade flow.
525531
526532
Override:
527533
@@ -572,16 +578,15 @@ def test_prepare(self):
572578
# pylint: disable=inherit-non-class
573579
class IntegrityCase(UpgradeCommon, _create_meta(20, "integrity_case")):
574580
"""
575-
Test case for validating invariants across upgrades.
581+
Test case for validating upgrade invariants.
576582
577583
Override:
578584
579585
* ``invariant`` to return a JSON-serializable value representing
580586
the invariant to check.
581587
582-
The ``invariant`` method is called both before and after the upgrade,
583-
and the results are compared.
584-
588+
The ``invariant`` method is called both before and after the upgrade, and the results
589+
are compared. If there is any difference the test fails.
585590
586591
.. example::
587592

0 commit comments

Comments
 (0)