From 2871f63d192bb897649515a059ee9a09b6ea5b66 Mon Sep 17 00:00:00 2001 From: Eli Courtwright Date: Mon, 15 Jul 2013 16:23:26 -0400 Subject: [PATCH 1/2] Update parallel.py When I try to run self.assertEqual(x, y) in one of my tests, it fails with the error AttributeError: 'SubTest' object has no attribute '_type_equality_funcs' This is because we never call TestCase.__init__ in the SubTest.__init__, and according to the docstring, "If it is necessary to override the __init__ method, the base class __init__ method must always be called." (you can see this by running "pydoc unittest.TestCase") TestCase.__init__ expects to be passed a string which is the name of the method being tested; this will fail if you pass a non-existing method name. Unfortunately, we're manually constructing SubTest and then passing that as the "self" to our real test case method, defined elsewhere, so we can't use that method's name. Fortunately, it's okay if we don't pass the real method name, so long as we pass any method name that is known to exist; I use "__init__" since that will always exist. --- wd/parallel.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wd/parallel.py b/wd/parallel.py index 4039912..a31111b 100644 --- a/wd/parallel.py +++ b/wd/parallel.py @@ -69,6 +69,7 @@ def multiply(test): class SubTest(unittest.TestCase): def __init__(self, driver=None): + unittest.TestCase(self, '__init__') # call with known method name to initialize properly self.driver = driver self.driver.implicitly_wait(30) From a1f4dc78bfbcb2fa77514721a1c112f87c5507d1 Mon Sep 17 00:00:00 2001 From: Eli Courtwright Date: Mon, 15 Jul 2013 16:24:20 -0400 Subject: [PATCH 2/2] Update parallel.py fixed typo from previous commit --- wd/parallel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wd/parallel.py b/wd/parallel.py index a31111b..907078a 100644 --- a/wd/parallel.py +++ b/wd/parallel.py @@ -69,7 +69,7 @@ def multiply(test): class SubTest(unittest.TestCase): def __init__(self, driver=None): - unittest.TestCase(self, '__init__') # call with known method name to initialize properly + unittest.TestCase.__init__(self, '__init__') # call with known method name to initialize properly self.driver = driver self.driver.implicitly_wait(30)