theY4Kman / pytest-only

pytest plug-in to run single tests with the "only" mark (perfect for use with auto-rerunners!)
https://pypi.org/project/pytest-only/
MIT License
18 stars 5 forks source link

Add documentation on how to use this on fixtures #9

Open TauPan opened 3 years ago

TauPan commented 3 years ago

Which is really easy:

@pytest.mark.parametrize(
    'data, expected',
    [({'test': 'data'}, {'tst': 'dt'}),
     pytest.param({'foo': 'bar'}, {'f': 'br'}, marks=[pytest.mark.only])])
def test_remove_dict_vowels(self, data, expected):
    assert remove_dict_vowels(data) == expected

But I'm too lazy to write more than this example right now, just wanted to point this out.

And I wanted to say thanks because this is really the easiest way if I have a test with bucketloads of data from fixtures testing many cases and I want to temporarily concentrate on a single one or a subset of those cases.

theY4Kman commented 3 years ago

Ooo, this is a good idea! Thank you :)

And I'm glad you find it useful, too. I use it so much that I have a couple Live Templates in PyCharm to quickly add module-level and function-level marks for it :P

(__import__ lets me use them anywhere, without having to have pytest imported. getattr is necessary for the decorator form, which, until PEP 614 was released in Python 3.9, does not allow dotted paths after a function call. They're both surrounded by some ugly-ass comments that are really hard to miss in git diffs, so I don't accidentally commit them)

pytest-only-live-templates.xml These can be installed by copying this XML and pasting them into the Live Templates configuration (which I think is pretty neat) ```xml ```