Hi Orestis,

thanks for your mail and sorry for the hassle - to be honest 
i haven't cared much for integrating unittests myself yet.  
But i try to improve now :) 

On Sat, Sep 20, 2008 at 22:59 +0100, Orestis Markou wrote:
> After attending Holger's talk at PyCon UK about py.test, I decided to  
> try it out. I'm using a recent svn checkout.
>
> I had a bunch of tests (around 50 of them), all inheriting from  
> unittest. I expected that they would work out of the box with py.test,  
> and was surprised when they weren't. I tried adding the py_unittest  
> conftest.py file to my project, but I got this traceback:
> 
> Traceback (most recent call last):
>    File "/opt/local/Library/Frameworks/Python.framework/Versions/ 
> Current/bin/py.test", line 8, in <module>
>      load_entry_point('py==1.0.0a1', 'console_scripts', 'py.test')()
>    File "/Users/orestis/Developer/pylib/py/cmdline/pytest.py", line 5,  
> in main
>      py.test.cmdline.main()
>    File "/Users/orestis/Developer/pylib/py/test/cmdline.py", line 12,  
> in main
>      config.parse(args)
>    File "/Users/orestis/Developer/pylib/py/test/config.py", line 46,  
> in parse
>      self._conftest.setinitial(args)
>    File "/Users/orestis/Developer/pylib/py/test/conftesthandle.py",  
> line 30, in setinitial
>      self._path2confmods[None] = self.getconftestmodules(anchor)
>    File "/Users/orestis/Developer/pylib/py/test/conftesthandle.py",  
> line 44, in getconftestmodules
>      clist.append(importconfig(conftestpath))
>    File "/Users/orestis/Developer/pylib/py/test/conftesthandle.py",  
> line 74, in importconfig
>      mod = configpath.pyimport()
>    File "/Users/orestis/Developer/pylib/py/path/local/local.py", line  
> 413, in pyimport
>      mod = __import__(modname, None, None, ['__doc__'])
>    File "/Users/orestis/Developer/pysmell/conftest.py", line 52, in  
> <module>
>      class UnitTestFunction(py.__.test.item.Function):
> AttributeError: 'module' object has no attribute 'item'

i think this is a mismatch between the py lib checkout and 
the conftest.  If you checkout 

    http://codespeak.net/svn/py/trunk

* install it e.g. by doing "python setup.py develop" and 
* put contrib/py_unittest/conftest.py into pysmell

then it should work fine now. I actually just tested
with your current GIT version and all but two tests fail
(they look like expected failures). 

> I expected that the naming conventions would be enough, but I was  
> surprised again by the fact that py.test requires "test_" methods  
> rather than just "test" methods. Fixing that, I was again surprised  
> that my tests still weren't running, and after some guesswork realized  
> that the class they were in didn't start with "Test".

hum, methods/functions only need to start with "test" in any case.  
If not there is a bug and i am happy about an example. 

unittest-collected classes don't need to follow a naming
convention - they just need to subclass TestCase as usual. 

py.test-collected classes indeed need to start with "Test". 

So i am a bit confused what your exact problem actually was
here.  Btw, for debugging, "py.test --collectonly" is helpful. 

> I suggest that you add this crucial information in a more clear way  
> (it is there, but not very discoverable) or even better, integrate the  
> py_unittest collection into py.test - this way people can try out  
> their old tests with py.test, rather than having to convert everything.

good point.  So far i was hesitant with promoting it 
because i wanted to spend a bit more time into docs and 
an infrastructure that helps with checking that things 
are consistent.  It apparently gets about time now :) 

best, 
holger

-- 
collaborative expert contracting: http://merlinux.eu 
PyPy  Python/Compiler tool chain: http://codespeak.net/pypy 
pylib py.test/greenlets/svn APIs: http://pylib.org 
_______________________________________________
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev

Reply via email to