From 6a7455b528f4b12e2d76ac9670a74fceee2812ce Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 15 Oct 2000 01:09:17 +0000 Subject: [PATCH] Some fixes for Python 2.0 compatibility [SVN r7944] --- test_extclass.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test_extclass.py b/test_extclass.py index 1912b237..a458dbb0 100644 --- a/test_extclass.py +++ b/test_extclass.py @@ -15,10 +15,11 @@ a single long parameter. File "", line 1, in ? TypeError: function requires exactly 1 argument; 0 given - >>> ext = Foo('foo') - Traceback (innermost last): - File "", line 1, in ? - TypeError: illegal argument type for built-in operation + >>> try: ext = Foo('foo') + ... except TypeError, err: + ... assert re.match( + ... '(illegal argument type for built-in operation)|(an integer is required)', str(err)) + ... else: print 'no exception' >>> ext = Foo(1) @@ -144,6 +145,8 @@ Functions expecting an std::auto_ptr parameter will not accept a raw Baz ... except RuntimeError, err: ... assert re.match("Object of extension class 'Baz' does not wrap <.*>.", ... str(err)) + ... else: + ... print 'no exception' We can pass std::auto_ptr where it is expected @@ -159,6 +162,8 @@ And if the auto_ptr has given up ownership? ... try: baz_clone.clone() ... except RuntimeError, err: ... assert re.match('Converting from python, pointer or smart pointer to <.*> is NULL.', str(err)) + ... else: + ... print 'no exeption' Polymorphism also works: @@ -232,6 +237,7 @@ Overloading tests: ... assert re.match( ... 'No overloaded functions match [(]Range, string[)]\. Candidates are:\n.*\n.*', ... str(e)) + ... else: print 'no exception' Sequence tests: >>> len(Range(3, 10)) @@ -368,7 +374,7 @@ some __str__ and __repr__ tests: >>> range = Range(5, 20) >>> str(range) '(5, 20)' - >>> assert re.match('', repr(range)) + >>> assert re.match('', repr(range)) __hash__ and __cmp__ tests: