mirror of
https://github.com/novoid/date2name.git
synced 2026-06-14 02:51:18 +00:00
Continue on all tests, even if one fails.
The retraction of the -x parameter for pytest ensures that all test functions defined are actually used. Previously, testing stopped immediately, conveying an incomplete picture of date2name's work implemented. Testing the retraction option -r, there is no need for a delay between the indivdual options, either.
This commit is contained in:
parent
2e3654fd78
commit
7504aead86
3 changed files with 25 additions and 29 deletions
10
Makefile
10
Makefile
|
|
@ -13,8 +13,10 @@
|
|||
# chmod +x *
|
||||
# make ./Makefile
|
||||
#
|
||||
# to run the tests. The test sequence either stops at the first test
|
||||
# failing, or after completion.
|
||||
# to run the tests. The test sequence will explicitly report if a test
|
||||
# was passed successfully, or failed. If you want to script to stop on
|
||||
# the first encounter of a test failed, add option -x on the commands
|
||||
# set below
|
||||
|
||||
# pytest -xv test_date2name.py # only pytest for Python 3 is present
|
||||
pytest-3 -xv test_date2name.py # pytest if Python 2 and Python 3 coexist
|
||||
# pytest -v test_date2name.py # only pytest for Python 3 is present
|
||||
pytest-3 -v test_date2name.py # pytest if Python 2 and Python 3 coexist
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
# author: nbehrnd@yahoo.com
|
||||
# license: GPL v3, 2021.
|
||||
# date: 2021-08-30 (YYYY-MM-DD)
|
||||
# edit: 2021-09-17 (YYYY-MM-DD)
|
||||
# edit: 2021-09-28 (YYYY-MM-DD)
|
||||
#
|
||||
"""Test pad for functions by date2name with pytest.
|
||||
|
||||
|
|
@ -225,8 +225,8 @@ def test_short_pattern_YYMMDD(arg1):
|
|||
assert os.path.isfile(new)
|
||||
os.remove(new)
|
||||
|
||||
import time, os, sys
|
||||
@pytest.mark.parametrize("arg1", ["default", "short", "compact", "month", "withtime"])
|
||||
@pytest.mark.parametrize("arg1", ["default", "short", "compact",
|
||||
"month", "withtime"])
|
||||
@pytest.mark.parametrize("arg2", ["-r", "--remove"])
|
||||
def test_remove_stamp(arg1, arg2):
|
||||
"""Check the retraction of the leading time stamp."""
|
||||
|
|
@ -242,15 +242,11 @@ def test_remove_stamp(arg1, arg2):
|
|||
TFILE = "_".join([prepend, BASIS])
|
||||
with open(TFILE, mode = "w") as newfile:
|
||||
newfile.write("This is a test file.")
|
||||
time.sleep(2)
|
||||
|
||||
test = getoutput(f"python3 {PROGRAM} {TFILE} {arg2}")
|
||||
time.sleep(2)
|
||||
|
||||
assert os.path.isfile(TFILE) is False # absence of stamped file
|
||||
assert os.path.isfile(BASIS) # presence unstamped file
|
||||
|
||||
try:
|
||||
os.remove("test.txt")
|
||||
except OSError:
|
||||
print("Running remove test, file 'test.txt' was not erased.")
|
||||
sys.exit()
|
||||
os.remove("test.txt") # succesful space cleaning for next test
|
||||
assert os.path.isfile("test.txt") is False
|
||||
|
|
|
|||
|
|
@ -72,11 +72,13 @@
|
|||
# chmod +x *
|
||||
# make ./Makefile
|
||||
#
|
||||
# to run the tests. The test sequence either stops at the first test
|
||||
# failing, or after completion.
|
||||
# to run the tests. The test sequence will explicitly report if a test
|
||||
# was passed successfully, or failed. If you want to script to stop on
|
||||
# the first encounter of a test failed, add option -x on the commands
|
||||
# set below
|
||||
|
||||
# pytest -xv test_date2name.py # only pytest for Python 3 is present
|
||||
pytest-3 -xv test_date2name.py # pytest if Python 2 and Python 3 coexist
|
||||
# pytest -v test_date2name.py # only pytest for Python 3 is present
|
||||
pytest-3 -v test_date2name.py # pytest if Python 2 and Python 3 coexist
|
||||
#+end_src
|
||||
|
||||
|
||||
|
|
@ -90,7 +92,7 @@
|
|||
# author: nbehrnd@yahoo.com
|
||||
# license: GPL v3, 2021.
|
||||
# date: 2021-08-30 (YYYY-MM-DD)
|
||||
# edit: 2021-09-17 (YYYY-MM-DD)
|
||||
# edit: 2021-09-28 (YYYY-MM-DD)
|
||||
#
|
||||
"""Test pad for functions by date2name with pytest.
|
||||
|
||||
|
|
@ -363,8 +365,8 @@
|
|||
successful to retract this stamp.
|
||||
|
||||
#+begin_src python :tangle test_date2name.py
|
||||
import time, os, sys
|
||||
@pytest.mark.parametrize("arg1", ["default", "short", "compact", "month", "withtime"])
|
||||
@pytest.mark.parametrize("arg1", ["default", "short", "compact",
|
||||
"month", "withtime"])
|
||||
@pytest.mark.parametrize("arg2", ["-r", "--remove"])
|
||||
def test_remove_stamp(arg1, arg2):
|
||||
"""Check the retraction of the leading time stamp."""
|
||||
|
|
@ -380,16 +382,12 @@
|
|||
TFILE = "_".join([prepend, BASIS])
|
||||
with open(TFILE, mode = "w") as newfile:
|
||||
newfile.write("This is a test file.")
|
||||
time.sleep(2)
|
||||
|
||||
test = getoutput(f"python3 {PROGRAM} {TFILE} {arg2}")
|
||||
time.sleep(2)
|
||||
|
||||
assert os.path.isfile(TFILE) is False # absence of stamped file
|
||||
assert os.path.isfile(BASIS) # presence unstamped file
|
||||
|
||||
try:
|
||||
os.remove("test.txt")
|
||||
except OSError:
|
||||
print("Running remove test, file 'test.txt' was not erased.")
|
||||
sys.exit()
|
||||
os.remove("test.txt") # succesful space cleaning for next test
|
||||
assert os.path.isfile("test.txt") is False
|
||||
#+end_src
|
||||
|
|
|
|||
Loading…
Reference in a new issue