---
source: https://iinventedlight.com/library/notes/pytest-markers.md
title: "pytest markers label tests and can be registered to avoid unknown-mark warnings"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (pytest docs); MIT (pytest-dev/pytest (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: pytest docs, How to mark test functions, MIT (https://raw.githubusercontent.com/pytest-dev/pytest/main/LICENSE); pytest-dev/pytest (GitHub), How to mark test functions (pytest source docs), MIT (https://raw.githubusercontent.com/pytest-dev/pytest/main/LICENSE)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: medium
untested: "Not reproduced (2026-11-16). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: pytest markers"
tags: [pytest, markers, testing, strict-markers]
client: Librarian
sources:
  - id: S1
    title: "How to mark test functions"
    publisher: pytest docs
    url: https://docs.pytest.org/en/stable/how-to/mark.html
    accessed: 2026-11-16
    license: "MIT"
  - id: S2
    title: "How to mark test functions (pytest source docs)"
    publisher: pytest-dev/pytest (GitHub)
    url: https://github.com/pytest-dev/pytest/blob/main/doc/en/how-to/mark.rst
    accessed: 2026-11-16
    license: "MIT"
---
# pytest markers label tests and can be registered to avoid unknown-mark warnings
**Answer:** You can mark test functions so you can select or deselect them, for example with `-m`. You can register new markers programmatically in a `pytest_configure` hook. Registered marks appear in pytest's help text and do not emit warnings.

## Unknown marks

Unregistered marks avoid silently doing something surprising due to mistyped names. Unregistered marks applied with `@pytest.mark.name_of_the_mark` will always emit a warning. When the `strict_markers` configuration option is set, any unknown marks applied with that decorator will trigger an error. You can enforce this validation by setting `strict_markers` in your configuration, or with `addopts = ["--strict-markers"]`.

Note that everything past the `:` after the mark name is an optional description.

## See also

- [python-unittest](https://iinventedlight.com/library/notes/python-unittest/)
- [python-typing-annotations](https://iinventedlight.com/library/notes/python-typing-annotations/)
- [pytest-parametrize](https://iinventedlight.com/library/notes/pytest-parametrize/)

## Claims

- id: C1
  claim: You can register markers in a pytest_configure hook.
  source: S1
  evidence: "you can register new markers programmatically in a"

- id: C2
  claim: Unregistered marks emit a warning to catch mistyped names.
  source: S2
  evidence: "will always emit a warning in order to avoid silently doing something"

- id: C3
  claim: strict_markers turns an unknown mark into an error.
  source: S2
  evidence: "any unknown marks applied"

- id: C4
  claim: Text past the colon after a mark name is an optional description.
  source: S2
  evidence: "everything past the ``:`` after the mark name is an optional description."

## Sources

- [S1] How to mark test functions. pytest docs. https://docs.pytest.org/en/stable/how-to/mark.html . License: MIT. Accessed 2026-11-16.

- [S2] How to mark test functions (pytest source docs). pytest-dev/pytest (GitHub). https://github.com/pytest-dev/pytest/blob/main/doc/en/how-to/mark.rst . License: MIT. Accessed 2026-11-16.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: pytest docs, How to mark test functions, MIT (https://raw.githubusercontent.com/pytest-dev/pytest/main/LICENSE); pytest-dev/pytest (GitHub), How to mark test functions (pytest source docs), MIT (https://raw.githubusercontent.com/pytest-dev/pytest/main/LICENSE). Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
