[pytest-dev] Access fixtures from unittest.TestCase

Wolfgang Schnerring ws at gocept.com
Fri Apr 4 11:21:58 CEST 2014


Hello,

is there a way to access a fixture object from inside a unitest.TestCase test
function? As far as I understand, the way to combine fixtures and TestCase is
like this:

  import pytest, unittest

  @pytest.mark.usefixtures('tmpdir')
  class MyTest(unittest.TestCase):

       def test_something(self):
           # XXX how can I get to ``tmpdir`` here?

But there seems to be no way to get to the fixture object, which is rather
constraining. Or am I missing something?

Thanks for your help,
Wolfgang



More information about the Pytest-dev mailing list