What’s the meaning of the percentages displayed for each test on PyTest?

This is a makeshift progress bar. It displays the “percentage of work” done so far — most probably, total completed tests by the total number of tests to run (that it precalculated at the start). If your tests ran for longer, you would probably see the number in the line changing as it crunches through … Read more

How to speed up pytest

Using the norecursedirs option in pytest.ini or tox.ini can save a lot of collection time, depending on what other files you have in your working directory. My collection time is roughly halved for a suite of 300 tests when I have that in place (0.34s vs 0.64s). If you’re already using tox like I am, … Read more

Grouping tests in pytest: Classes vs plain functions

This answer presents two compelling use-cases for a TestClass in pytest: Joint parametrization of multiple test methods belonging to a given class. Reuse of test data and test logic via subclass inheritance Joint parametrization of multiple test methods belonging to a given class. The pytest parametrization decorator, @pytest.mark.parametrize, can be used to make inputs available … Read more

pytest using fixtures as arguments in parametrize

Will was on the right path, you should use request.getfixturevalue to retrieve the fixture. But you can do it right in the test, which is simpler. @pytest.mark.parametrize(‘dirname, expected’, [ (‘dir1_fixture’, ‘expected1’), (‘dir2_fixture’, ‘expected2’)]) def test_directory_command(dirname, expected, request): result = my_package.directory_command(request.getfixturevalue(dirname)) assert result == expected Another way is to use lazy-fixture plugin: @pytest.mark.parametrize(‘dirname, expected’, [ (pytest.lazy_fixture(‘dir1_fixture’), … Read more

What does indirect = True/False in pytest.mark.parametrize do/mean?

With indirect=True you can parametrize your fixture, False – default value. Example: import pytest @pytest.fixture def fixture_name(request): return request.param @pytest.mark.parametrize(‘fixture_name’, [‘foo’, ‘bar’], indirect=True) def test_indirect(fixture_name): assert fixture_name == ‘baz’ So this example generates two tests. First one gets from fixture_name value foo, because this fixture for this test runs with parametization. Second test gets bar … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)