testing-conventions 0.0.76

Enforce testing conventions in libraries (Python, TypeScript, and Rust).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Clean fixture for R3: env is set via patch.dict(os.environ, {...}) in a fixture.
# Reading os.environ is fine; only direct mutation is flagged.
import os

import pytest
from unittest.mock import patch


@pytest.fixture(autouse=True)
def env():
    with patch.dict(os.environ, {"MYPROJECT_TOKEN": "test-token"}):
        yield


def describe_widget():
    def it_reads_the_token():
        assert os.environ["MYPROJECT_TOKEN"] == "test-token"