diff options
author | Erik Rose <erik@votizen.com> | 2012-03-14 11:13:13 -0700 |
---|---|---|
committer | Erik Rose <erik@votizen.com> | 2012-03-14 11:13:13 -0700 |
commit | 9e59403da7702cfed386cbe54678d98e8cbc86cb (patch) | |
tree | f935591041dca500e15eb94e11ed91007ff22ff4 | |
parent | a014b52003813b92563946329b93cf31cb32eb3d (diff) | |
download | nose-9e59403da7702cfed386cbe54678d98e8cbc86cb.tar.gz |
Stop using the `assert` statement in `ok_` and `eq_` so they work under `python -O`. Closes #504.
-rw-r--r-- | CHANGELOG | 5 | ||||
-rw-r--r-- | nose/tools/trivial.py | 6 |
2 files changed, 7 insertions, 4 deletions
@@ -11,8 +11,9 @@ - Fixed Unicode issue on Python 3.1 with coverage (#442) - fixed class level fixture handling in multiprocessing plugin - Clue in the ``unittest`` module so it no longer prints traceback frames for - our clones of their simple assertion helpers. (#453). - Patch by Erik Rose. + our clones of their simple assertion helpers (#453). Patch by Erik Rose. +- Stop using the ``assert`` statement in ``ok_`` and ``eq_`` so they work under + ``python -O`` (#504). Patch by Erik Rose. 1.1.2 diff --git a/nose/tools/trivial.py b/nose/tools/trivial.py index 34d5569..cf83efe 100644 --- a/nose/tools/trivial.py +++ b/nose/tools/trivial.py @@ -18,13 +18,15 @@ __unittest = 1 def ok_(expr, msg=None): """Shorthand for assert. Saves 3 whole characters! """ - assert expr, msg + if not expr: + raise AssertionError(msg) def eq_(a, b, msg=None): """Shorthand for 'assert a == b, "%r != %r" % (a, b) """ - assert a == b, msg or "%r != %r" % (a, b) + if not a == b: + raise AssertionError(msg or "%r != %r" % (a, b)) # |