From 045f946439a682d90af23111412e2e9c8e06c4d5 Mon Sep 17 00:00:00 2001 From: Norwid Behrnd Date: Thu, 21 Nov 2024 21:17:57 +0100 Subject: [PATCH] style: more compact generation of pytest.ini Signed-off-by: Norwid Behrnd --- pytest.ini | 6 +++--- test_appendfilename.py | 2 +- test_generator.org | 35 +++++++++++++---------------------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/pytest.ini b/pytest.ini index 1bd280b..f986737 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,5 +1,5 @@ [pytest] markers = - default: appendfilename's default string insertions - prepend: appendfilename's optional -p/--prepend flag - smart: appendfilename's optional --smart-prepend flag + default: test appendfilename's default string insertion + prepend: test appendfilename's optional -p/--prepend flag + smart_prepend: test appendfilename's optional --smart-prepend flag diff --git a/test_appendfilename.py b/test_appendfilename.py index eb1fdf4..35e2f11 100755 --- a/test_appendfilename.py +++ b/test_appendfilename.py @@ -214,7 +214,7 @@ arg3_values = [ test_cases = list(product(arg1_values, arg2_values, arg3_values)) -@pytest.mark.smart +@pytest.mark.smart_prepend @pytest.mark.parametrize("arg1, arg2, arg3", test_cases) def test_smart_prepend(arg1, arg2, arg3): """test the insertion of a new string just past the time stamp diff --git a/test_generator.org b/test_generator.org index 0b1a26e..d27de88 100755 --- a/test_generator.org +++ b/test_generator.org @@ -104,17 +104,16 @@ python -m pytest -m "prepend" : t If the previous block was evaluated as .TRUE. (=t=), test script and - Makefile may be tangled right now by =C-c C-v t=. After closing - this =.org= file, deploy them as indicated earlier. + =pytest.ini= may be tangled right now by =C-c C-v t=. After closing + this =.org= file, deploy them as indicated. * Building the tests ** Building file =pytest.ini= - Markers file =pytest.ini= defines and which are used in file - =test_appendfilename.py= allows to constrain the run of - =pytest=. Rather than to launch a check on all tests, a call - like e.g., + File =pytest.ini= lists markers in file =test_appendfilename.py= + to optionally constrain =pytest= tests. Rather than to launch + a check on all tests defined, a call like e.g., #+begin_src bash :tangle no python -m pytest -m "prepend" @@ -123,11 +122,13 @@ python -m pytest -m "prepend" only checks those of set =prepend=. At present, tests are grouped as - + =default= appendfilename's default string insertions - + =prepend= corresponding to either appendfilename's optional =-p= - or =--prepend= flag, and - + =smart= corresponding to appendfilename's optional - =--smart-prepend= flag + #+begin_src shell :tangle pytest.ini +[pytest] +markers = + default: test appendfilename's default string insertion + prepend: test appendfilename's optional -p/--prepend flag + smart_prepend: test appendfilename's optional --smart-prepend flag + #+end_src It is possible to run one, two, or all three groups in one run of pytest, for instance @@ -136,16 +137,6 @@ python -m pytest -m "prepend" pytest-3 test_appendfilename.py -m "default and prepend" -v #+end_src - The content of =pytest.ini=: - - #+begin_src shell :tangle pytest.ini -[pytest] -markers = - default: appendfilename's default string insertions - prepend: appendfilename's optional -p/--prepend flag - smart: appendfilename's optional --smart-prepend flag - #+end_src - ** Building the test script *** header section @@ -398,7 +389,7 @@ arg3_values = [ test_cases = list(product(arg1_values, arg2_values, arg3_values)) -@pytest.mark.smart +@pytest.mark.smart_prepend @pytest.mark.parametrize("arg1, arg2, arg3", test_cases) def test_smart_prepend(arg1, arg2, arg3): """test the insertion of a new string just past the time stamp