How to use the pytest.mark.parametrize function in pytest

To help you get started, we’ve selected a few pytest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kengz / SLM-Lab / test / spec / test_spec.py View on Github external
@pytest.mark.parametrize('spec_file,spec_name', [
    ('experimental/sil/ppo_sil_cartpole.json', 'ppo_sil_shared_cartpole'),
    ('experimental/sil/ppo_sil_cartpole.json', 'ppo_sil_separate_cartpole'),
    ('experimental/sil/ppo_sil_cartpole.json', 'ppo_sil_rnn_shared_cartpole'),
    ('experimental/sil/ppo_sil_cartpole.json', 'ppo_sil_rnn_separate_cartpole'),
])
def test_ppo_sil(spec_file, spec_name):
    run_trial_test(spec_file, spec_name)
github onicagroup / runway / tests / module / test_terraform.py View on Github external
    @pytest.mark.parametrize('terraform_version, expected, exception',
                             [('0.11.6', '0.11.6', does_not_raise()),
                              ({'test': '0.12', 'prod': '0.11.6'},  # deprecated
                               '0.12', does_not_raise()),
                              ({'*': '0.11.6', 'test': '0.12'},  # deprecated
                               '0.12', does_not_raise()),
                              ({'*': '0.11.6', 'prod': '0.12'},  # deprecated
                               '0.11.6', does_not_raise()),
                              ({'prod': '0.11.6'}, None,  # deprecated
                               does_not_raise()),
                              (None, None, does_not_raise()),
                              (13, None, pytest.raises(TypeError))])
    def test_resolve_version(self, runway_context, terraform_version,
                             expected, exception):
        """Test resolve_version."""
        config = {'something': None}
        if terraform_version:
github tribe29 / checkmk / tests-py3 / unit / cmk / base / test_config.py View on Github external
@pytest.mark.parametrize("hostname,core_name,result", [
    ("testhost1", "cmc", None),
    ("testhost2", "cmc", "command1"),
    ("testhost3", "cmc", "smart"),
    ("testhost3", "nagios", "ping"),
])
def test_host_config_explicit_check_command(monkeypatch, hostname, core_name, result):
    ts = Scenario().add_host(hostname)
    ts.set_option("monitoring_core", core_name)
    ts.set_option(
        "host_check_commands",
        [
            ("command1", [], ["testhost2"], {}),
            ("command2", [], ["testhost2"], {}),
            ("smart", [], ["testhost3"], {}),
        ],
    )
github zulip / zulip-terminal / tests / model / test_model.py View on Github external
    @pytest.mark.parametrize('topic, is_muted', [
        ((1, 'stream muted & unmuted topic'), True),
        ((2, 'muted topic'), True),
        ((1, 'muted stream muted topic'), True),
        ((2, 'unmuted topic'), False),
    ])
    def test_is_muted_topic(self, topic, is_muted, stream_dict, model):
        model.stream_dict = stream_dict
        model.muted_streams = [1]
        model.muted_topics = [
            ['Stream 2', 'muted topic'],
            ['Stream 1', 'muted stream muted topic'],
        ]
        assert model.is_muted_topic(stream_id=topic[0],
                                    topic=topic[1]) == is_muted
github wemake-services / wemake-python-styleguide / tests / test_visitors / test_ast / test_functions / test_useless_lambda.py View on Github external
@pytest.mark.parametrize('lambda_def', [
    'lambda x',
    'lambda x=1',
    'lambda *, x=1',
    'lambda x, y',
    'lambda x, *, y',
    'lambda y, *, x',
    'lambda *, x, y',
    'lambda *, y, x',
    'lambda x, *y',
    'lambda x, **z',
    'lambda x, *y, **z',
    'lambda *y, **z',
    'lambda *only_y',
    'lambda **only_z',
])
@pytest.mark.parametrize('inner_def', [
github comic / evalutils / tests / test_stats.py View on Github external
@pytest.mark.parametrize(
    "a,b",
    [
        [
            np.random.randint(0, 2, (6, 6), dtype=np.bool),
            np.random.randint(0, 2, (6, 6), dtype=np.bool),
        ]
        for _ in range(20)
    ],
)
@pytest.mark.parametrize("voxelspace", [None, (0.3, 0.8)])
@pytest.mark.parametrize("connectivity", [0, 1, 2])
def test_modified_hd(a, b, voxelspace, connectivity):
    d_a = sitk_surface_distance(a, b, voxelspace, connectivity)
    d_b = sitk_surface_distance(b, a, voxelspace, connectivity)
    mhd = max(d_a.mean(), d_b.mean())
github alphagov / notifications-admin / tests / app / main / views / test_register.py View on Github external
@pytest.mark.parametrize('email_address, expected_value', [
    ("first.last@example.com", "First Last"),
    ("first.middle.last@example.com", "First Middle Last"),
    ("first.m.last@example.com", "First Last"),
    ("first.last-last@example.com", "First Last-Last"),
    ("first.o'last@example.com", "First O’Last"),
    ("first.last+testing@example.com", "First Last"),
    ("first.last+testing+testing@example.com", "First Last"),
    ("first.last6@example.com", "First Last"),
    ("first.last.212@example.com", "First Last"),
    ("first.2.last@example.com", "First Last"),
    ("first.2b.last@example.com", "First Last"),
    ("first.1.2.3.last@example.com", "First Last"),
    ("first.last.1.2.3@example.com", "First Last"),
    # Instances where we can’t make a good-enough guess:
    ("example123@example.com", ""),
    ("f.last@example.com", ""),
github thu-coai / cotk / tests / dataloader / test_sentence_classification.py View on Github external
	@pytest.mark.parametrize("load_dataloader", all_load_dataloaders)
	def test_get_next_batch(self, load_dataloader):
		super().base_test_get_next_batch(load_dataloader())
github bonlime / pytorch-tools / tests / tta_wrapper / test_tta.py View on Github external
@pytest.mark.parametrize("merge", ["gmean", "max", "gmean"])
def test_wrapper_segm(merge):
    m = NoOp()
    inp = INPUT / 15.0  # make sure max is less that 1 to avoid overflow
    tta_m = TTA(m, segm=True, h_flip=True, v_flip=True, h_shift=1, v_shift=-1, rotation=90, merge=merge)
    assert (inp - tta_m(inp)).mean() < 1e-6
github thoth-station / adviser / tests / steps / test_tensorflow_avx2.py View on Github external
    @pytest.mark.parametrize(
        "recommendation_type,decision_type,cpu_family,cpu_model",
        [
            (RecommendationType.STABLE, None, None, None),  # No CPU info.
            (RecommendationType.TESTING, None, -1, -1),  # No AVX2 support in CPU.
            (None, DecisionType.RANDOM, 0x6, 0xF),  # A Dependency Monkey run.
        ],
    )
    def test_no_include(
        self,
        builder_context: PipelineBuilderContext,
        recommendation_type,
        decision_type: DecisionType,
        cpu_family: Optional[int],
        cpu_model: Optional[int],
    ) -> None:
        """Test not including this pipeline unit step."""