[py-dev] Information for unittest refugees
Orestis Markou
orestis at orestis.gr
Sun Sep 21 12:41:39 CEST 2008
> 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).
>
Ah, I was following your slides and checkout out the py_unittest
directory directly - copying contrib/py_unittest/conftest.py worked!
>> 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.
Sorry, I was confused because I didn't prepend Test to my classes.
Indeed no underscore was needed.
>
>
> 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.
My problem was that I had a lot of test_* methods in a class that
didn't start with Test (not inheriting from unittest). I couldn't find
that bit in the documentation that mentioned that - I will try to
write up a small py.test in 1 minute document that you could use.
>> 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 :)
I suggest that version 1 should have this bit in, it will help a lot
of people to give it a casual go :)
Regards,
Orestis
More information about the Pytest-dev
mailing list