Loading...
Loading...
Compare original and translation side by side
uvuvuvuv --versionpyproject.tomluv inituv add --dev pytest pytest-covuv run pytest --couvuv --versionpyproject.tomluv inituv add --dev pytest pytest-covuv run pytest --coRED → Write ONE failing test for the next behavior
GREEN → Write the MINIMUM code to make it pass
REFACTOR → Clean up without changing behavior
REPEATuv run pytest红(RED)→ 为下一个行为编写一个失败的测试用例
绿(GREEN)→ 编写最少的代码使测试通过
重构(REFACTOR)→ 在不改变行为的前提下清理代码
重复(REPEAT)uv run pytestundefinedundefineddef test_does_expected_thing_when_given_input(self):
result = function_under_test(input_value)
assert result == expected
def test_raises_when_given_invalid_input(self):
with pytest.raises(ValueError):
function_under_test(bad_input)undefineddef test_does_expected_thing_when_given_input(self):
result = function_under_test(input_value)
assert result == expected
def test_raises_when_given_invalid_input(self):
with pytest.raises(ValueError):
function_under_test(bad_input)undefineduv run pytest # all tests
uv run pytest tests/test_foo.py # single file
uv run pytest -k "test_name" # by name pattern
uv run pytest --cov=src # with coverage
uv run pytest -x # stop on first failureuv run pytest # 运行所有测试
uv run pytest tests/test_foo.py # 运行单个文件的测试
uv run pytest -k "test_name" # 按名称模式运行测试
uv run pytest --cov=src # 运行测试并生成覆盖率报告
uv run pytest -x # 遇到第一个失败时停止运行uv add <package> # add dependency
uv add --dev <package> # add dev dependency
uv remove <package> # remove dependency
uv sync # sync environment from lockfile
uv run <command> # run in managed environment
uv lock # regenerate lockfileuv runpyproject.tomluv.lockuv add <package> # 添加依赖项
uv add --dev <package> # 添加开发依赖项
uv remove <package> # 移除依赖项
uv sync # 根据锁定文件同步环境
uv run <command> # 在管理的环境中运行命令
uv lock # 重新生成锁定文件uv runpyproject.tomluv.lock