1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
import pytest
# the example schemas have a number of successes and failures
# hard-code them here to allow more flexibility in the tests below
PASSES = 9
FAILURES = 3
def test_pyprojecttoml(pytester):
pytester.copy_example("example")
pytester.makepyprojecttoml(
"""
[tool.pytest.ini_options]
asdf_schema_root = 'resources/schemas'
asdf_schema_tests_enabled = 'true'
asdf_schema_ignore_unrecognized_tag = 'true'
"""
)
result = pytester.runpytest()
result.assert_outcomes(passed=PASSES, failed=FAILURES)
def test_asdf_tests_argument(pytester):
pytester.copy_example("example")
pytester.makepyprojecttoml(
"""
[tool.pytest.ini_options]
asdf_schema_root = 'resources/schemas'
asdf_schema_ignore_unrecognized_tag = 'true'
"""
)
result = pytester.runpytest("--asdf-tests")
result.assert_outcomes(passed=PASSES, failed=FAILURES)
@pytest.mark.parametrize(
"skip_cfg, passes, failures",
(("passing-1.0.0", PASSES - 3, FAILURES),),
)
def test_skip_examples(pytester, skip_cfg, passes, failures):
pytester.copy_example("example")
pytester.makepyprojecttoml(
f"""
[tool.pytest.ini_options]
asdf_schema_root = 'resources/schemas'
asdf_schema_tests_enabled = 'true'
asdf_schema_ignore_unrecognized_tag = 'true'
asdf_schema_skip_examples = "{skip_cfg}"
"""
)
result = pytester.runpytest()
result.assert_outcomes(passed=passes, failed=failures)
@pytest.mark.parametrize(
"skip_cfg, passes, failures",
(("passing-1.0.0", PASSES - 4, FAILURES),),
)
def test_skip_names(pytester, skip_cfg, passes, failures):
pytester.copy_example("example")
pytester.makepyprojecttoml(
f"""
[tool.pytest.ini_options]
asdf_schema_root = 'resources/schemas'
asdf_schema_tests_enabled = 'true'
asdf_schema_ignore_unrecognized_tag = 'true'
asdf_schema_skip_names = "{skip_cfg}"
"""
)
result = pytester.runpytest()
result.assert_outcomes(passed=passes, failed=failures)
@pytest.mark.parametrize(
"skip_cfg, passes, failures, skips",
(
("passing-1.0.0.yaml", PASSES - 4, FAILURES, 4),
("passing-1.0.0.yaml::*", PASSES - 4, FAILURES, 4),
("passing-1.0.0.yaml::test_example_0", PASSES - 1, FAILURES, 1),
("passing-1.0.0.yaml::test_example_1", PASSES - 1, FAILURES, 1),
("nested/nested-1.0.0.yaml", PASSES - 4, FAILURES, 4),
),
)
def test_skips(pytester, skip_cfg, passes, failures, skips):
pytester.copy_example("example")
pytester.makepyprojecttoml(
f"""
[tool.pytest.ini_options]
asdf_schema_root = 'resources/schemas'
asdf_schema_tests_enabled = 'true'
asdf_schema_ignore_unrecognized_tag = 'true'
asdf_schema_skip_tests = "{skip_cfg}"
"""
)
result = pytester.runpytest()
result.assert_outcomes(passed=passes, failed=failures, skipped=skips)
@pytest.mark.parametrize(
"xfail_cfg, xpasses, xfailures",
(
("passing-1.0.0.yaml", 4, 0),
("passing-1.0.0.yaml::*", 4, 0),
("failing-1.0.0.yaml", 1, 2),
),
)
def test_xfail(pytester, xfail_cfg, xpasses, xfailures):
pytester.copy_example("example")
pytester.makepyprojecttoml(
f"""
[tool.pytest.ini_options]
asdf_schema_root = 'resources/schemas'
asdf_schema_tests_enabled = 'true'
asdf_schema_ignore_unrecognized_tag = 'true'
asdf_schema_xfail_tests = "{xfail_cfg}"
"""
)
result = pytester.runpytest()
result.assert_outcomes(passed=PASSES - xpasses, failed=FAILURES - xfailures, xpassed=xpasses, xfailed=xfailures)
|