style: more compact generation of pytest.ini

Signed-off-by: Norwid Behrnd <nbehrnd@yahoo.com>
This commit is contained in:
Norwid Behrnd 2024-11-21 21:17:57 +01:00
parent 548f4f848e
commit 045f946439
3 changed files with 17 additions and 26 deletions

View file

@ -1,5 +1,5 @@
[pytest] [pytest]
markers = markers =
default: appendfilename's default string insertions default: test appendfilename's default string insertion
prepend: appendfilename's optional -p/--prepend flag prepend: test appendfilename's optional -p/--prepend flag
smart: appendfilename's optional --smart-prepend flag smart_prepend: test appendfilename's optional --smart-prepend flag

View file

@ -214,7 +214,7 @@ arg3_values = [
test_cases = list(product(arg1_values, arg2_values, 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) @pytest.mark.parametrize("arg1, arg2, arg3", test_cases)
def test_smart_prepend(arg1, arg2, arg3): def test_smart_prepend(arg1, arg2, arg3):
"""test the insertion of a new string just past the time stamp """test the insertion of a new string just past the time stamp

View file

@ -104,17 +104,16 @@ python -m pytest -m "prepend"
: t : t
If the previous block was evaluated as .TRUE. (=t=), test script and 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 =pytest.ini= may be tangled right now by =C-c C-v t=. After closing
this =.org= file, deploy them as indicated earlier. this =.org= file, deploy them as indicated.
* Building the tests * Building the tests
** Building file =pytest.ini= ** Building file =pytest.ini=
Markers file =pytest.ini= defines and which are used in file File =pytest.ini= lists markers in file =test_appendfilename.py=
=test_appendfilename.py= allows to constrain the run of to optionally constrain =pytest= tests. Rather than to launch
=pytest=. Rather than to launch a check on all tests, a call a check on all tests defined, a call like e.g.,
like e.g.,
#+begin_src bash :tangle no #+begin_src bash :tangle no
python -m pytest -m "prepend" python -m pytest -m "prepend"
@ -123,11 +122,13 @@ python -m pytest -m "prepend"
only checks those of set =prepend=. At present, tests are only checks those of set =prepend=. At present, tests are
grouped as grouped as
+ =default= appendfilename's default string insertions #+begin_src shell :tangle pytest.ini
+ =prepend= corresponding to either appendfilename's optional =-p= [pytest]
or =--prepend= flag, and markers =
+ =smart= corresponding to appendfilename's optional default: test appendfilename's default string insertion
=--smart-prepend= flag 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 It is possible to run one, two, or all three groups in one run of
pytest, for instance pytest, for instance
@ -136,16 +137,6 @@ python -m pytest -m "prepend"
pytest-3 test_appendfilename.py -m "default and prepend" -v pytest-3 test_appendfilename.py -m "default and prepend" -v
#+end_src #+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 ** Building the test script
*** header section *** header section
@ -398,7 +389,7 @@ arg3_values = [
test_cases = list(product(arg1_values, arg2_values, 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) @pytest.mark.parametrize("arg1, arg2, arg3", test_cases)
def test_smart_prepend(arg1, arg2, arg3): def test_smart_prepend(arg1, arg2, arg3):
"""test the insertion of a new string just past the time stamp """test the insertion of a new string just past the time stamp