The TestRunId.test_get_run_id_default_timestamp test fixture can fail if the after date time has 59 seconds for reasons that are irrelevant to the code.
To Reproduce
It's dependent on the timestamp so it's hard to reproduce naturally unless you get lucky (or unlucky).
Changed this line of code:
after = datetime.now()
to
after = datetime.now().replace(second=59)
in flepimop/gempyor_pkg/tests/file_paths/test_run_id.py.
Run the unit test with pytest flepimop/gempyor_pkg/tests/file_paths/test_run_id.py -v.
Then the test fixture should fail with an error that looks like:
FAILED flepimop/gempyor_pkg/tests/file_paths/test_run_id.py::TestRunId::test_get_run_id_default_timestamp - ValueError: second must be in 0..59
Expected behavior
This test fixture should be able to handle a datetime object with a seconds of 59, I think it just needs to be done more carefully using timedeltas instead of haphazardly messing with the components. Instead of
after = after.replace(microsecond=0, second=after.second + 1)
something like
after = (after + timedelta(seconds=1)).replace(microsecond=0)
or similar.
Environment, if relevant:
OS: Platform independent
Python Version: 3.11.9, but likely present in all 3.* versions.
flepiMoP branch and/or commit if relevant: main, b05e92e16501fd6c3fb0d1ac1c374b578b0ddbc7
Describe the bug
The
TestRunId.test_get_run_id_default_timestamp
test fixture can fail if theafter
date time has 59 seconds for reasons that are irrelevant to the code.To Reproduce
It's dependent on the timestamp so it's hard to reproduce naturally unless you get lucky (or unlucky).
to
in
flepimop/gempyor_pkg/tests/file_paths/test_run_id.py
.pytest flepimop/gempyor_pkg/tests/file_paths/test_run_id.py -v
.Expected behavior
This test fixture should be able to handle a
datetime
object with a seconds of 59, I think it just needs to be done more carefully using timedeltas instead of haphazardly messing with the components. Instead ofsomething like
or similar.
Environment, if relevant:
main
,b05e92e16501fd6c3fb0d1ac1c374b578b0ddbc7