Closed luxedo closed 2 months ago
Nice catch! Could you add a test please.
ATM it's probably easiest to add a case to https://github.com/scipy/scipy_doctest/blob/main/scipy_doctest/tests/module_cases.py
(we'll need to refactor tests into explicitly testing DTChecker, but that's separate)
I don't know how to create such test. I want to test the failing behavior, so shouldn't I place tests at failure_cases.py
?
196
197 >>> [1, 2, 3]
Expected:
[1, 2, 3, 4]
Got:
[1, 2, 3]
Yes indeed, failure_cases.py
or failure_cases_2.py
. You probably want something like
--- a/scipy_doctest/tests/failure_cases.py
+++ b/scipy_doctest/tests/failure_cases.py
@@ -15,3 +15,10 @@ def func10():
>>> import numpy as np
>>> np.arraY([1, 2, 3])
"""
+
+
+def func_lengths():
+ """
+ >>> [1, 2, 3]
+ [1, 2, 3, 4]
+ """
diff --git a/scipy_doctest/tests/test_testmod.py b/scipy_doctest/tests/test_testmod.py
index 0c0a839..2de341b 100644
--- a/scipy_doctest/tests/test_testmod.py
+++ b/scipy_doctest/tests/test_testmod.py
@@ -99,6 +99,13 @@ def test_user_context():
config=config)
+def test_wrong_lengths():
+ config = DTConfig()
+ res, _ = _testmod(failure_cases, strategy=[failure_cases.func_lengths],
+ config=config)
+ assert res.failed == 1 # or use raise_on_error=True and pytest.raises
+
+
Minor: as far as commit message acronyms go, FIX:
is not a thing. You probably want BUG:
going forward.
Fixes https://github.com/scipy/scipy_doctest/issues/161 by iterating the longest array