summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKumar McMillan <kumar.mcmillan@gmail.com>2012-03-14 12:14:50 -0700
committerKumar McMillan <kumar.mcmillan@gmail.com>2012-03-14 12:14:50 -0700
commit3983ae3636eb286c0610f113e77356435d686018 (patch)
treef935591041dca500e15eb94e11ed91007ff22ff4
parenta014b52003813b92563946329b93cf31cb32eb3d (diff)
parent9e59403da7702cfed386cbe54678d98e8cbc86cb (diff)
downloadnose-3983ae3636eb286c0610f113e77356435d686018.tar.gz
Merge pull request #505 from erikrose/kill-assert
Stop using the `assert` statement in `ok_` and `eq_` so they work under ...
-rw-r--r--CHANGELOG5
-rw-r--r--nose/tools/trivial.py6
2 files changed, 7 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 0bab124..0f7a9e9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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))
#