[TIP] pytest fixtures started after unittest.TestCase.setUpClass

Dan Nealschneider dan.nealschneider at schrodinger.com
Thu Jan 4 16:53:41 PST 2018


On Thu, Jan 4, 2018 at 3:51 PM, Bruno Oliveira <nicoddemus at gmail.com> wrote:

> Hi Dan,
>
> (Cool to know you use pytest-qt :))
>
We don't actually use pytest qt! I'd love to, but the way that our current
qt-based tests run is problematic. I'll take your smiley face as a another
encouragement to move towards pytest-qt...


> On Thu, Jan 4, 2018 at 7:31 PM Dan Nealschneider <dan.nealschneider@
> schrodinger.com> wrote:
>
>> 1. How should I ensure that start_qapp is run before any test or test
>> setup?
>>
>
> Unfortunately the only way I know of is to change your setUpClass method
> into an autouse fixture, this technique is detailed here:
> https://github.com/pytest-dev/pytest/issues/517#issuecomment-128150676
>
Yeah, that's what I suspected... I can totally easily fix this one test,
but unfortunately we have tens of thousands of tests, so I won't be
updating them by hand super soon. It would be nice if unittest2pytest
updated setUp and setUpClass, then I could make some
serious progress. Maybe I'll take a stab at updating unittest2pytest.

>
>
>
>> 2. Does this seem like a bug/RFE that I should report to pytest?
>>
>
> This has actually been discussed extensively [1] and there is an
> implementation idea which is easy to implement and would make xunit
> setup/fixtures work better together [2] but there's the concern of breaking
> backward compatibility: definitely there are people who depend on the
> current behavior and just changing this would break their test suite in
> subtle and no fun ways [3].
>
> [1] https://github.com/pytest-dev/pytest/issues/517
> [2] https://github.com/pytest-dev/pytest/issues/517#issuecomment-228830714
> [3] https://github.com/pytest-dev/pytest/issues/517#issuecomment-229506416
>
Cool. Thanks, Bruno!

>
> Cheers,
> Bruno.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20180104/ceb65d78/attachment.htm>


More information about the testing-in-python mailing list