Skip to content

Commit a98b318

Browse files
committed
refactor test
add some tests, update some assert messages, rewrite some asserts all without a change in functionality
1 parent 4faafc3 commit a98b318

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

fastcore/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ def test_stdout(f, exp, regex=False):
7878
"Test that `f` prints `exp` to stdout, optionally checking as `regex`"
7979
s = io.StringIO()
8080
with redirect_stdout(s): f()
81-
if regex: assert re.search(exp, s.getvalue()) is not None
81+
if regex: assert re.search(exp, s.getvalue()) is not None, f"regex '{exp}' did not not match stdout '{s.getvalue()}'"
8282
else: test_eq(s.getvalue(), f'{exp}\n' if len(exp) > 0 else '')
8383

8484
# %% ../nbs/00_test.ipynb 40
8585
def test_warns(f, show=False):
8686
with warnings.catch_warnings(record=True) as w:
8787
f()
88-
test_ne(len(w), 0)
88+
assert w, "No warnings raised"
8989
if show:
9090
for e in w: print(f"{e.category}: {e.message}")
9191

0 commit comments

Comments
 (0)