Hello all,

 

I am trying to use the funcargs feature with my unittest.Testcase
subclasses but it appears that py.test fails to pass the additional
arguments to the unittest test method. I haven't found any discussion of
this anywhere, so I'm making my first post here.

 

Here is a simple example--

 

# ./conftest.py

def pytest_funcarg__val1(request):

    return True

 

def pytest_funcarg__val2(request):

    return False

 

 

# ./test_myunittest.py

class Test(unittest.TestCase):

    def test_Name(self, val1, val2):

        assert (val1 and val2)

 

 

The result-

 

================================================= test session starts
=================================================

[...snip...]

self = <UnitTestFunction 'test_Name'>

 

    def runtest(self):

        target = self.obj

        args = self._args

>       target(*args)

E       TypeError: test_Name() takes exactly 3 arguments (1 given)

 

C:\Python26\lib\site-packages\py-1.0.2-py2.6.egg\py\test\plugin\pytest_u
nittest.py:65: TypeError

============================================== 1 failed in 0.08 seconds
===============================================

 

 

As you can see, py.test isn't passing  the 2 funcargs from conftest.py.
However, if you simply remove "unittest.TestCase" from
test_myunittest.py, the py.test fails as intended-

 

self = < test_myunittest.py.Test instance at 0x00E98AF8>, val1 = True,
val2 = False

 

    def test_Name(self, val1, val2):

>       assert (val1 and val2)

E       assert (True and False)

 

tests\math\ test_myunittest.py:18: AssertionError

============================================== 1 failed in 0.08 seconds
===============================================

 

 

Is there any way to incorporate the funcargs feature into the unittest
compatibility?

 

Thanks, and keep up the great tool!

Greg

_______________________________________________
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev

Reply via email to