Skip to content

Commit d750f0f

Browse files
author
Fabien Coelho
committed
assert False -> pytest.fail
1 parent b9873d2 commit d750f0f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

test.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def setgetdel(cache):
9393
# assert KEY not in cache
9494
try:
9595
val = cache[KEY]
96-
assert False, "should raise KeyError"
96+
pytest.fail("should raise KeyError")
9797
except Exception as e:
9898
assert isinstance(e, KeyError)
9999
# int value
@@ -117,7 +117,7 @@ def setgetdel_bytes(cache):
117117
assert cache.pop(key, cst) == cst
118118
try:
119119
cache.pop(key)
120-
assert False, "should raise KeyError"
120+
pytest.fail("should raise KeyError")
121121
except KeyError as e:
122122
assert True, "KeyError was raised"
123123

@@ -241,7 +241,7 @@ def test_redis():
241241
setgetdel(c2)
242242
try:
243243
c2.__iter__()
244-
assert False, "should raise an Exception"
244+
pytest.fail("not supported")
245245
except Exception as e:
246246
assert "not implemented yet" in str(e)
247247

@@ -404,7 +404,7 @@ def test_methods():
404404
ctu.cacheMethods(cs, s, sum_n1="x.")
405405
try:
406406
ctu.cacheMethods(cs, s, no_such_method="?.")
407-
assert False, "exception must be raised"
407+
pytest.fail("exception must be raised")
408408
except Exception as e:
409409
assert "missing method" in str(e)
410410

@@ -441,7 +441,7 @@ def test_corners():
441441
try:
442442
js = ctu.JsonSerde()
443443
js.deserialize("foo", "bla", 42)
444-
assert False, "exception must be raised"
444+
pytest.fail("exception must be raised")
445445
except Exception as e:
446446
assert "Unknown serialization format" in str(e)
447447

@@ -466,17 +466,17 @@ def test_resilience():
466466
c = ctu.TwoLevelCache(d, b, False)
467467
try:
468468
c["foo"] = "bla"
469-
assert False, "must raise an exception"
469+
pytest.fail("must raise an exception")
470470
except Exception:
471471
assert True, "expecting exception"
472472
try:
473473
c["foo"]
474-
assert False, "must raise an exception"
474+
pytest.fail("must raise an exception")
475475
except Exception:
476476
assert True, "expecting exception"
477477
try:
478478
del c["foo"]
479-
assert False, "must raise an exception"
479+
pytest.fail("must raise an exception")
480480
except Exception:
481481
assert True, "expecting exception"
482482

0 commit comments

Comments
 (0)