pytest-ordering icon indicating copy to clipboard operation
pytest-ordering copied to clipboard

Doesn't work when using inside a class

Open konpatp opened this issue 10 years ago • 2 comments

If my code is something like this:

class Test(TestCase):
    i = 0

    @pytest.mark.run(order=1)
    def test_c(self):
        assert self.i == 0
        self.i += 1

    @pytest.mark.run(order=2)
    def test_b(self):
        assert self.i == 1
        self.i += 1

    @pytest.mark.run(order=3)
    def test_a(self):
        assert self.i == 2
        self.i += 1

It says 'Empty test suite.', and when I change the marker into something like @pytest.mark.first, it still doesn't work. It seems to me that pytest doesn't obey these marks anymore.

How do I solve this ? or I'm doing it wrongly ?

konpatp avatar Jun 25 '15 10:06 konpatp

This definitely looks like a bug. Probably a few bugs.

Try starting the order from 0. It looks like there are problems when the "order" ordinal is higher than the number of tests, and it's zero-indexed.

Thanks for reporting this. I'll need to address this in the next release.

ftobia avatar Jun 28 '15 00:06 ftobia

using 'pytest-ordering 0.5' with index starts at 0 works well for me.

Thanks for pytest-ordering. :)

azzamsa avatar Jul 05 '18 05:07 azzamsa