Skip to content

Commit

Permalink
On Python 2 the format of exception differs to Python 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamDumpleton committed Jan 12, 2023
1 parent 2418edd commit 7cbdc95
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions tests/test_object_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import unittest
import types
import operator
import sys
import re

is_pypy = '__pypy__' in sys.builtin_module_names

Expand Down Expand Up @@ -1878,12 +1878,12 @@ def __init__(self, *args, **kwargs):
with self.assertRaises(TypeError) as e:
Object(self='self')

self.assertTrue("got multiple values for argument 'self'" in str(e.exception))
self.assertNotEqual(re.match(".*got multiple values for (keyword )?argument 'self'.*", str(e.exception)), None)

with self.assertRaises(TypeError) as e:
wrapt.wrappers.CallableObjectProxy(Object)(self='self')

self.assertTrue("got multiple values for argument 'self'" in str(e.exception))
self.assertNotEqual(re.match(".*got multiple values for (keyword )?argument 'self'.*", str(e.exception)), None)

def test_self_keyword_argument_on_class_init_2(self):
class Object:
Expand All @@ -1894,12 +1894,12 @@ def __init__(self, *args, **kwargs):
with self.assertRaises(TypeError) as e:
Object(arg1='arg1', self='self')

self.assertTrue("got multiple values for argument 'self'" in str(e.exception))
self.assertNotEqual(re.match(".*got multiple values for (keyword )?argument 'self'.*", str(e.exception)), None)

with self.assertRaises(TypeError) as e:
wrapt.wrappers.CallableObjectProxy(Object)(arg1='arg1', self='self')

self.assertTrue("got multiple values for argument 'self'" in str(e.exception))
self.assertNotEqual(re.match(".*got multiple values for (keyword )?argument 'self'.*", str(e.exception)), None)

def test_self_keyword_argument_on_class_init_renamed(self):
class Object:
Expand Down Expand Up @@ -2020,14 +2020,14 @@ def __init__(self, *args, **kwargs):
with self.assertRaises(TypeError) as e:
Object(self='self')

self.assertTrue("got multiple values for argument 'self'" in str(e.exception))
self.assertNotEqual(re.match(".*got multiple values for (keyword )?argument 'self'.*", str(e.exception)), None)

wrapper = wrapt.wrappers.PartialCallableObjectProxy(Object, self='self')

with self.assertRaises(TypeError) as e:
o = wrapper()

self.assertTrue("got multiple values for argument 'self'" in str(e.exception))
self.assertNotEqual(re.match(".*got multiple values for (keyword )?argument 'self'.*", str(e.exception)), None)

def test_self_keyword_argument_on_class_init_1b(self):
class Object:
Expand All @@ -2038,14 +2038,14 @@ def __init__(self, *args, **kwargs):
with self.assertRaises(TypeError) as e:
Object(self='self')

self.assertTrue("got multiple values for argument 'self'" in str(e.exception))
self.assertNotEqual(re.match(".*got multiple values for (keyword )?argument 'self'.*", str(e.exception)), None)

wrapper = wrapt.wrappers.PartialCallableObjectProxy(Object)

with self.assertRaises(TypeError) as e:
o = wrapper(self='self')

self.assertTrue("got multiple values for argument 'self'" in str(e.exception))
self.assertNotEqual(re.match(".*got multiple values for (keyword )?argument 'self'.*", str(e.exception)), None)

def test_self_keyword_argument_on_class_init_2a(self):
class Object:
Expand All @@ -2056,14 +2056,14 @@ def __init__(self, *args, **kwargs):
with self.assertRaises(TypeError) as e:
Object(arg1='arg1', self='self')

self.assertTrue("got multiple values for argument 'self'" in str(e.exception))
self.assertNotEqual(re.match(".*got multiple values for (keyword )?argument 'self'.*", str(e.exception)), None)

wrapper = wrapt.wrappers.PartialCallableObjectProxy(Object, arg1='arg1', self='self')

with self.assertRaises(TypeError) as e:
o = wrapper()

self.assertTrue("got multiple values for argument 'self'" in str(e.exception))
self.assertNotEqual(re.match(".*got multiple values for (keyword )?argument 'self'.*", str(e.exception)), None)

def test_self_keyword_argument_on_class_init_2b(self):
class Object:
Expand All @@ -2074,14 +2074,14 @@ def __init__(self, *args, **kwargs):
with self.assertRaises(TypeError) as e:
Object(arg1='arg1', self='self')

self.assertTrue("got multiple values for argument 'self'" in str(e.exception))
self.assertNotEqual(re.match(".*got multiple values for (keyword )?argument 'self'.*", str(e.exception)), None)

wrapper = wrapt.wrappers.PartialCallableObjectProxy(Object)

with self.assertRaises(TypeError) as e:
o = wrapper(arg1='arg1', self='self')

self.assertTrue("got multiple values for argument 'self'" in str(e.exception))
self.assertNotEqual(re.match(".*got multiple values for (keyword )?argument 'self'.*", str(e.exception)), None)

def test_self_keyword_argument_on_class_init_renamed_1(self):
class Object:
Expand Down

0 comments on commit 7cbdc95

Please sign in to comment.