[pytest]
markers =
smoke: mark a test as a smoke test
addopts = -v
# test_sample.py
import pytest
@pytest.mark.smoke
def test_example():
assert 1 + 1 == 2
# test_pytest_ini.py
import subprocess
import sys
import re
def test_pytest_ini_configuration():
# Run pytest in the current directory without extra args
result = subprocess.run([sys.executable, '-m', 'pytest'], capture_output=True, text=True)
output = result.stdout + result.stderr
# Check verbose output: look for 'test_example' in output and '-v' effect (e.g., test names shown)
assert 'test_example' in output
assert re.search(r'collected \d+ items', output)
# Check no warnings about unknown markers
assert 'PytestUnknownMarkWarning' not in output
assert 'WARNING' not in output or 'smoke' in output
The pytest.ini file sets the smoke marker and adds -v to addopts for verbose output by default.
The test_sample.py file contains a simple test marked with @pytest.mark.smoke.
The automation script test_pytest_ini.py runs pytest as a subprocess without extra arguments to verify the configuration.
It asserts that the test name appears in the output, indicating verbose mode is active.
It also checks that no warnings about unknown markers appear, confirming the marker is recognized.
This approach tests the pytest.ini configuration end-to-end without modifying test runner commands.