From 0014e65c1d77bcc7e89cec19974077ffbb329376 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 29 Aug 2009 06:58:54 -0500 Subject: [PATCH 1/2] fix interpreting is/is not/in/not in --HG-- branch : trunk --- py/code/_assertionnew.py | 4 ++++ py/code/testing/test_assertion.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/py/code/_assertionnew.py b/py/code/_assertionnew.py index 29f76efd4..73430e9ae 100644 --- a/py/code/_assertionnew.py +++ b/py/code/_assertionnew.py @@ -68,6 +68,10 @@ operator_map = { ast.LtE : "<=", ast.Gt : ">", ast.GtE : ">=", + ast.Is : "is", + ast.IsNot : "is not", + ast.In : "in", + ast.NotIn : "not in" } unary_map = { diff --git a/py/code/testing/test_assertion.py b/py/code/testing/test_assertion.py index 14c5837d6..858ed3eca 100644 --- a/py/code/testing/test_assertion.py +++ b/py/code/testing/test_assertion.py @@ -65,6 +65,22 @@ def test_assert_multiline_2(): s = str(e) assert s.startswith('assert 2 ==') +def test_in(): + try: + assert "hi" in [1, 2] + except AssertionError: + e = exvalue() + s = str(e) + assert s.startswith("assert 'hi' in") + +def test_is(): + try: + assert 1 is 2 + except AssertionError: + e = exvalue() + s = str(e) + assert s.startswith("assert 1 is 2") + def test_assert_non_string_message(): class A: def __str__(self): From c2d0c52086069cc9a6faa093acc213fc0e76dbe4 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 29 Aug 2009 07:03:19 -0500 Subject: [PATCH 2/2] replace iteritems() with items() --HG-- branch : trunk --- py/rest/rst.py | 4 ++-- py/test/plugin/pytest_terminal.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/py/rest/rst.py b/py/rest/rst.py index 6cf88d1f2..8eb7beeed 100644 --- a/py/rest/rst.py +++ b/py/rest/rst.py @@ -120,7 +120,7 @@ class Rest(AbstractNode): return "" link_texts = [] # XXX this could check for duplicates and remove them... - for link, target in self.links.iteritems(): + for link, target in self.links.items(): link_texts.append(".. _`%s`: %s" % (escape(link), target)) return "\n" + "\n".join(link_texts) + "\n\n" @@ -401,7 +401,7 @@ class Directive(Paragraph): txt = super(Directive, self).text() txt = '.. %s::%s' % (self.name, txt[namechunksize + 3:],) options = '\n'.join([' :%s: %s' % (k, v) for (k, v) in - self.options.iteritems()]) + self.options.items()]) if options: txt += '\n%s' % (options,) diff --git a/py/test/plugin/pytest_terminal.py b/py/test/plugin/pytest_terminal.py index e42e934b8..6ed4f09a6 100644 --- a/py/test/plugin/pytest_terminal.py +++ b/py/test/plugin/pytest_terminal.py @@ -441,7 +441,7 @@ def folded_skips(skipped): key = entry.path, entry.lineno, entry.message d.setdefault(key, []).append(event) l = [] - for key, events in d.iteritems(): + for key, events in d.items(): l.append((len(events),) + key) return l