From 2995d65720680be97a9ccd9800498bdf4aff542a Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 10 Jun 2010 13:50:07 -0500 Subject: [PATCH] fix assertion interpretation when the operator is ** --HG-- branch : trunk --- CHANGELOG | 1 + py/_code/_assertionnew.py | 1 + testing/code/test_assertion.py | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 704d6f292..a982210b0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -34,6 +34,7 @@ New features Bug fixes / Maintenance ++++++++++++++++++++++++++ +- fix assertion interpretation with the ** operator - fix issue105 assignment on the same line as a failing assertion - fix issue104 proper escaping for test names in junitxml plugin - fix issue57 -f|--looponfail to work with xpassing tests diff --git a/py/_code/_assertionnew.py b/py/_code/_assertionnew.py index e12fb932d..99d4abbf4 100644 --- a/py/_code/_assertionnew.py +++ b/py/_code/_assertionnew.py @@ -92,6 +92,7 @@ operator_map = { ast.LtE : "<=", ast.Gt : ">", ast.GtE : ">=", + ast.Pow : "**", ast.Is : "is", ast.IsNot : "is not", ast.In : "in", diff --git a/testing/code/test_assertion.py b/testing/code/test_assertion.py index ab28437b3..01bb57b27 100644 --- a/testing/code/test_assertion.py +++ b/testing/code/test_assertion.py @@ -146,6 +146,13 @@ def test_multiple_statements_per_line(): e = exvalue() assert "assert 1 == 2" in e.msg +def test_power(): + try: + assert 2**3 == 7 + except AssertionError: + e = exvalue() + assert "assert 8 == 7" in e.msg + class TestView: