python -m pytest test/
Runs all test cases in all test_*.py files within the project.
pytest test/test_xmlvalidator.py
Runs all test cases inside test/test_xmlvalidator.py.
pytest test/test_xmlvalidator.py test/test_xml_validator_utils.py
Runs all tests from multiple test files.
You can run a single specific test case using pytest by specifying the test module name and the test function name.
Basic Syntax:
pytest test/test_module.py::test_function_name
Examples:
pytest test/test_xmlvalidator.py::test_find_schemas_namespace_matching_success
Runs only the test_find_schemas_namespace_matching_success function inside test/test_xmlvalidator.py.
pytest test/test_xmlvalidator.py::test_find_schemas_namespace_matching_success test/test_xml_validator_utils.py::test_match_namespace_to_schema_valid_target_namespace
Runs two specific test cases from two different files.
pytest -v
Shows detailed test output (pass/fail status).
pytest -v test/test_xmlvalidator.py::test_find_schemas_namespace_matching_success
pytest -x
Stops running when the first test fails.
pytest -x test/test_xmlvalidator.py::test_find_schemas_namespace_matching_success
pytest -s
Shows print output inside tests.
pytest -s test/test_xmlvalidator.py::test_find_schemas_namespace_matching_success
pytest --tb=long test/test_xmlvalidator.py::test_find_schemas_namespace_matching_success
pytest -k "schema"
Runs all tests where the function name contains "schema".