[pytest]# Filter unregistered marks. Suppresses all UserWarning# messages, and converts all other errors/warnings to errors.filterwarnings=errorignore::UserWarningtestpaths=tests
from__future__importannotationsfrompytestimportmark,xfail@mark.hellodeftest_say_hello(dummy_hello_str:str):assertisinstance(dummy_hello_str,str),f"Invalid test output type: ({type(dummy_hello_str)}). Should be of type str"assert(dummy_hello_str=="world"),f"String should have been 'world', not '{dummy_hello_str}'"print(f"Hello, {dummy_hello_str}!")@mark.always_passdeftest_pass():assertTrue,"test_pass() should have been True"@mark.xfaildeftest_fail():test_pass=Falseasserttest_pass,"This test is designed to fail"
conftest.py
Put conftest.py inside your tests/ directory. This file configures pytest, like providing test fixture paths so they can be accessed by tests.