Option C Tools
Loading...
Searching...
No Matches
test_pytest_missing_hint.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# tests/tests_cli/test_pytest_missing_hint.py
4
5"""
6Purpose
7-------
8OI-511 regression tests — ``oct test`` must surface an actionable install
9hint when pytest is missing. Because ``pytest`` is declared only in the
10``[project.optional-dependencies].test`` extra, users who install the
11runtime-only package and try to run ``oct test`` should see the hint
12rather than a bare ``No module named pytest`` traceback.
13
14Responsibilities
15----------------
16- ``_pytest_missing`` flags the sentinel string pytest emits when not
17 importable and returns False otherwise.
18- ``_PYTEST_INSTALL_HINT`` references the ``oct[test]`` extra so users
19 discover the canonical install path.
20
21Diagnostics
22-----------
23Domain: CLI-TESTS
24Levels:
25 L2 — test lifecycle
26 L3 — assertion details
27 L4 — deep tracing
28
29Contracts
30---------
31- Must never claim pytest is missing on a benign pytest failure (e.g.
32 assertion mismatch).
33"""
34
35from oct.cli import _PYTEST_INSTALL_HINT, _pytest_missing
36
37
39 sample = (
40 "C:\\Python\\python.exe: No module named pytest\n"
41 )
42 assert _pytest_missing(sample) is True
43
44
46 sample = (
47 "tests/foo.py::test_bar FAILED\n"
48 "AssertionError: nope\n"
49 )
50 assert _pytest_missing(sample) is False
51
52
54 assert "oct[test]" in _PYTEST_INSTALL_HINT
55 assert "pytest" in _PYTEST_INSTALL_HINT
Definition cli.py:1