[py-dev] Information for unittest refugees
Orestis Markou
orestis at orestis.gr
Sat Sep 20 23:59:19 CEST 2008
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 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".
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.
Best regards,
Orestis Markou
--
orestis at orestis.gr
http://orestis.gr/
More information about the Pytest-dev
mailing list