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 7cbdc95 commit ee6bab6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/test_object_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1946,12 +1946,12 @@ def __init__(_self, 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)

class TestArgumentUnpackingPartial(unittest.TestCase):

Expand Down Expand Up @@ -2171,14 +2171,14 @@ def __init__(_self, 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_overloaded_2b(self):
class Object:
Expand All @@ -2190,14 +2190,14 @@ def __init__(_self, 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)

if __name__ == '__main__':
unittest.main()

0 comments on commit ee6bab6

Please sign in to comment.