CraftSpider / dpytest

A package that assists in writing tests for discord.py
MIT License
103 stars 24 forks source link

Tests in classes don't work #65

Closed Bwallker closed 2 years ago

Bwallker commented 3 years ago

Is your feature request related to a problem? Please describe.

I would like to put my tests into classes, but if I do they don't work

image image

with this setup my test runs as you would expect and fails because of an exception I throw. this is supposed to happen.

image image

However when I put my test and fixture into a class it no longer works Having the fixture outside the class and the test inside the class doesn't work either

Describe the solution you'd like

If this is a limitation or a bug in dpytest, I would like it fixed. If it is something I am doing wrong, I would like to know how I can get it to work

Describe alternatives you've considered

Not putting my tests into classes. But I think this is messy and I prefer having them in classes :/

Additional context

Bwallker commented 3 years ago

The class I am using inherits from unittest.TestCase

Sillocan commented 3 years ago

unittest.TestCase does not support pytest fixtures out of the box. You have to do a bit of work to get them to work. This isn't a dpytest issue. https://docs.pytest.org/en/6.2.x/unittest.html

Sergeileduc commented 2 years ago

thanks for the answer @Sillocan !

I'll close the issue, I think.