Комментарии:
This was very helpful, thanks
Ответитьrly halpfull, thanks
ОтветитьThanks for the names triple tip, that helps a lot!
ОтветитьYour pytest videos are very nice, short and straight to the point. Thank you !!
ОтветитьThanks; I am fan of using fixture_id
def _fixture_id(kwargs: Dict[str, Any]) -> str:
"""Returns a user-friendly test case from the parametrized kwargs.
Parameters
----------
kwargs : Dict[str, Any]
Key-value pairs of test resources.
Returns
-------
str
"""
return ", ".join(f"{k} : {v}" for (k, v) in kwargs.items())
and decorate the test with
@pytest.mark.parametrize(
"kwargs",
_load_test_cases_from_json(),
ids=_fixture_id,
)
This is is easy because u only have 1 input and 1 expected output. What precisely to do when u have 3 inputs and 1 output? e.g. testing a function which adds 3 numbers
ОтветитьThe pytest.param is awesome to learn about! I love parametrizing tests at work, but it's not always immediately obvious which test case failed in a parametrized test with like ~10 cases. :--) Do you have any blog posts/videos that you've loved that dive deep into intermediate+ pytest usage? Or do i just rtfm
Ответитьpytest xdist video? any other parallelization mechanism for pytest?
ОтветитьShort, concise and accurate! Well done man.
ОтветитьIs there any way to use the variable generated at run time ( suppose - self.id) to use as a parameter inside pytest.mark.parametrize?
ОтветитьHow can I parametrize the whole class? Goal is to run the setup class and all the test cases for each value in the parametrized list
ОтветитьThe pytest.mark.parametrize decorator takes any iterable as the second parameter which made it easy for working through a lot of input and output for a game which were present in a file. Thanks for this!💜
Ответитьthanks, this made me look up the doc and found really cool parametrizing examples! BTW a parameter type-hinted as float actually accept an int as well, that surprised me too the first time I saw it (the numeric tower, PEP 484)
Ответить