Option C Tools
Loading...
Searching...
No Matches
tests_scaffold.test_scaffold_venv Namespace Reference

Classes

class  _FakeEnvBuilder

Functions

 _stub_envbuilder (pytest.MonkeyPatch monkeypatch)
 test_include_venv_true_creates_venv (Path tmp_path)
 test_include_venv_false_skips_venv (Path tmp_path)
 test_dry_run_true_never_creates_venv (Path tmp_path)
 test_preexisting_venv_is_skipped (Path tmp_path)
 test_venv_creation_failure_downgrades_to_warning (Path tmp_path, pytest.MonkeyPatch monkeypatch)
 test_result_is_scaffoldresult (Path tmp_path)

Detailed Description

Purpose
-------
FS-503 / FS-504 regression coverage — the ``include_venv`` flag on
:func:`oct.scaffold.run_scaffold` must:

* create ``.venv/`` via :mod:`venv` when True (the default),
* populate :attr:`ScaffoldResult.venv_path`,
* leave ``venv_path`` as ``None`` when False,
* skip (not overwrite) an existing ``.venv/``,
* downgrade :class:`OSError` from the builder to a warning message,
* make the venv discoverable to :func:`check_venv_health` — i.e. the
  scaffolded project is then "venv-found" even before activation.

The tests stub :class:`venv.EnvBuilder` so the suite never shells out to
``ensurepip`` — we are testing the *contract*, not the stdlib.

Diagnostics
-----------
Domain: SCAFFOLD-TESTS
Levels:
    L2 — test lifecycle

Contracts
---------
- ``include_venv=True`` → ``.venv/`` created; ``venv_path`` set.
- ``include_venv=False`` → no ``.venv/``; ``venv_path is None``.
- Pre-existing ``.venv/`` is recorded in ``skipped`` with a message.

Function Documentation

◆ _stub_envbuilder()

tests_scaffold.test_scaffold_venv._stub_envbuilder ( pytest.MonkeyPatch monkeypatch)
protected
Swap in the fake EnvBuilder for every test in this module.

Definition at line 69 of file test_scaffold_venv.py.

◆ test_dry_run_true_never_creates_venv()

tests_scaffold.test_scaffold_venv.test_dry_run_true_never_creates_venv ( Path tmp_path)
FS-503: include_venv=True combined with dry_run=True must not touch disk.

Definition at line 97 of file test_scaffold_venv.py.

◆ test_include_venv_false_skips_venv()

tests_scaffold.test_scaffold_venv.test_include_venv_false_skips_venv ( Path tmp_path)
FS-503: include_venv=False produces no .venv/ and venv_path stays None.

Definition at line 88 of file test_scaffold_venv.py.

◆ test_include_venv_true_creates_venv()

tests_scaffold.test_scaffold_venv.test_include_venv_true_creates_venv ( Path tmp_path)
FS-503: default include_venv=True materialises .venv/ at the project root.

Definition at line 76 of file test_scaffold_venv.py.

◆ test_preexisting_venv_is_skipped()

tests_scaffold.test_scaffold_venv.test_preexisting_venv_is_skipped ( Path tmp_path)
FS-503: a second run over an existing tree records .venv/ in skipped.

Definition at line 107 of file test_scaffold_venv.py.

◆ test_result_is_scaffoldresult()

tests_scaffold.test_scaffold_venv.test_result_is_scaffoldresult ( Path tmp_path)
Smoke: include_venv flag preserves the ScaffoldResult contract.

Definition at line 140 of file test_scaffold_venv.py.

◆ test_venv_creation_failure_downgrades_to_warning()

tests_scaffold.test_scaffold_venv.test_venv_creation_failure_downgrades_to_warning ( Path tmp_path,
pytest.MonkeyPatch monkeypatch )
FS-503: OSError from EnvBuilder must not abort scaffolding.

Definition at line 119 of file test_scaffold_venv.py.