Hi Sterling,

Looking at pytest’s code
<https://github.com/pytest-dev/pytest/blob/master/_pytest/python.py#L382>,
it seems it also needs a fixtureinfo object:

yield Function(name, parent=self, fixtureinfo=fixtureinfo)

This feels a little more complicate than it should to me, but I guess
that’s how things stand currently.

Sorry for not being able to help more, I’m in a rush today.

Cheers,
​

On Fri, Jan 12, 2018 at 9:51 PM Sterling Paramore <gnilr...@gmail.com>
wrote:

> I'm trying to build a plugin that will do something "special" with test
> functions that are prefixed with "case_".  However, I'm having trouble
> collecting those and using them with fixtures.
>
> in conftest.py I have
>
> def pytest_pycollect_makeitem(collector, name, obj):
>     if inspect.isfunction(obj) and (name.startswith('case_'):
>         Function = collector._getcustomclass("Function")
>         return Function(name, parent=collector)
>
> and in test_mything.py I have:
>
> class TestSomething():
>     @pytest.fixture
>     def scenario(self):
>         pass
>
>     def case_1(self, scenario):
>         pass
>
> But when I run the test, I get an error "TypeError: case_1() missing 1
> required positional argument: 'scenario'"
>
> How can I create the item so that it runs with the specific fixtures?
>
> Thanks,
> Sterling
> _______________________________________________
> pytest-dev mailing list
> pytest-dev@python.org
> https://mail.python.org/mailman/listinfo/pytest-dev
>
_______________________________________________
pytest-dev mailing list
pytest-dev@python.org
https://mail.python.org/mailman/listinfo/pytest-dev

Reply via email to