[py-svn] commit/py: hpk: fix pytest issue-tracker issue10, more careful bool-checking of assert reintepretation expressions

Bitbucket commits-noreply at bitbucket.org
Wed Jan 12 19:16:45 CET 2011


1 new changeset in py:

http://bitbucket.org/hpk42/py/changeset/9e9f978340a4/
changeset:   r1994:9e9f978340a4
user:        hpk
date:        2011-01-12 19:16:36
summary:     fix pytest issue-tracker issue10, more careful bool-checking of assert reintepretation expressions
affected #:  5 files (704 bytes)

--- a/CHANGELOG	Wed Jan 12 17:17:54 2011 +0100
+++ b/CHANGELOG	Wed Jan 12 19:16:36 2011 +0100
@@ -1,6 +1,9 @@
 Changes between 1.4.0 and 1.4.1
 ==================================================
 
+- fix (pytest-) issue10 and refine assertion reinterpretation
+  to avoid breaking if the __nonzero__ of an object fails
+
 - fix (pytest-) issue17 where python3 does not like "import *"
   leading to misrepresentation of import-errors in test modules
 


--- a/py/__init__.py	Wed Jan 12 17:17:54 2011 +0100
+++ b/py/__init__.py	Wed Jan 12 19:16:36 2011 +0100
@@ -8,7 +8,7 @@
 
 (c) Holger Krekel and others, 2004-2010
 """
-__version__ = '1.4.1.dev1'
+__version__ = '1.4.1.dev2'
 
 from py import _apipkg
 


--- a/py/_code/_assertionnew.py	Wed Jan 12 17:17:54 2011 +0100
+++ b/py/_code/_assertionnew.py	Wed Jan 12 19:16:36 2011 +0100
@@ -174,7 +174,12 @@
                                          __exprinfo_right=next_result)
             except Exception:
                 raise Failure(explanation)
-            if not result:
+            try:
+                if not result:
+                    break
+            except KeyboardInterrupt:
+                raise
+            except:
                 break
             left_explanation, left_result = next_explanation, next_result
 


--- a/setup.py	Wed Jan 12 17:17:54 2011 +0100
+++ b/setup.py	Wed Jan 12 19:16:36 2011 +0100
@@ -9,7 +9,7 @@
         name='py',
         description='library with cross-python path, ini-parsing, io, code, log facilities',
         long_description = open('README.txt').read(),
-        version='1.4.1.dev1',
+        version='1.4.1.dev2',
         url='http://pylib.org',
         license='MIT license',
         platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],


--- a/testing/code/test_assertion.py	Wed Jan 12 17:17:54 2011 +0100
+++ b/testing/code/test_assertion.py	Wed Jan 12 19:16:36 2011 +0100
@@ -303,3 +303,19 @@
         assert 're-run' not in s
         assert 'could not determine' in s
 
+def test_assert_raises_in_nonzero_of_object_pytest_issue10():
+    class A(object):
+        def __nonzero__(self):
+            raise ValueError(42)
+        def __lt__(self, other):
+            return A()
+        def __repr__(self):
+            return "<MY42 object>"
+    def myany(x):
+        return True
+    try:
+        assert not(myany(A() < 0))
+    except AssertionError:
+        e = exvalue()
+        s = str(e)
+        assert "<MY42 object>< 0" in s

Repository URL: https://bitbucket.org/hpk42/py/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the pytest-commit mailing list