Skip to content
Advertisement

Tag: fixtures

How to use pytest fixture with fixture factory?

In scikit-learn, there is a function parametrize_with_checks() that is used as a pytest fixture factory–it returns a pytest.mark.parametrize fixture, and is called as a decorator with an iterable of estimators, e.g. My issue is that my list of estimators may change (or I may have multiple lists), and each list I am setting up in a fixture. Here is a

How can request.param be annotated in indirect parametrization?

In the Indirect parametrization example I want to type hint request.param indicating a specific type, a str for example. The problem is since the argument to fixt must be the request fixture there seems to be no way to indicate what type the parameters passed through the “optional param attribute” should be (quoting the documentation). What are the alternatives? Perhaps

Advertisement