pytest-quickcheck / tests /

# -*- coding: utf-8 -*-
import pytest

@pytest.mark.randomize(("s1", "str"), fixed_length=32, ncalls=1)
def test_create_file_with_randomize(tmpdir, s1):
    p = tmpdir.mkdir("sub").join("tmp.txt")
    assert len(s1) == 32
    assert == s1
    assert len(tmpdir.listdir()) == 1

@pytest.mark.parametrize("prime", [3, 5, 7])
@pytest.mark.randomize(("i1", "int"), ("f1", "float"), max_num=100, ncalls=2)
def test_gen_parametrize_with_randomize_int_float(prime, i1, f1):
    assert prime in [3, 5, 7]
    assert isinstance(i1, int)
    assert i1 < 100
    assert isinstance(f1, float)

@pytest.mark.parametrize("prime", [3, 5, 7])
    ("d1", "{'x': int, 'y': [str, (int, int)], 'z': {'x': str}}"),
    max_num=100, max_length=5, ncalls=1
def test_gen_parametrize_with_randomize_dict(prime, d1):
    assert prime in [3, 5, 7]
    assert isinstance(d1, dict)
    assert isinstance(d1["x"], int)
    assert isinstance(d1["y"], list)
    assert isinstance(d1["y"][0], str)
    assert isinstance(d1["y"][1], tuple)
    assert isinstance(d1["y"][1][0], int)
    assert isinstance(d1["y"][1][1], int)
    assert isinstance(d1["z"], dict)
    assert isinstance(d1["z"]["x"], str)

@pytest.mark.parametrize("prime", [3, 5, 7])
@pytest.mark.randomize(s1=str, choices=["hello", "bye"])
def test_gen_parametrize_with_randomize_str_substitution(prime, s1):
    assert prime in [3, 5, 7]
    assert isinstance(s1, str)
    assert s1 in ("hello", "bye")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.