From 5ec96f1604fd5049bab70c826105187edc68f122 Mon Sep 17 00:00:00 2001 From: Matthew Mckee Date: Wed, 3 Dec 2025 19:16:34 +0000 Subject: [PATCH 1/5] Update fixture docs --- docs/fixtures/builtin.md | 0 docs/{ => fixtures}/fixtures.md | 0 zensical.toml | 5 ++++- 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 docs/fixtures/builtin.md rename docs/{ => fixtures}/fixtures.md (100%) diff --git a/docs/fixtures/builtin.md b/docs/fixtures/builtin.md new file mode 100644 index 00000000..e69de29b diff --git a/docs/fixtures.md b/docs/fixtures/fixtures.md similarity index 100% rename from docs/fixtures.md rename to docs/fixtures/fixtures.md diff --git a/zensical.toml b/zensical.toml index 23bfe323..7a7c0b26 100644 --- a/zensical.toml +++ b/zensical.toml @@ -16,7 +16,10 @@ nav = [ { "Home" = "index.md"}, { "Installation" = "installation.md"}, { "Tutorial" = "tutorial.md"}, - { "Fixtures" = "fixtures.md"}, + { "Fixtures" = [ + { "Fixtures" = "fixtures/fixtures.md"}, + { "Built In" = "fixtures/builtin.md"}, + ]}, { "Tags" = [ { "Parametrize" = "tags/parametrize.md"}, { "Skip" = "tags/skip.md"}, From 091ac0cd66267161df87e54bba8f5776361d39cd Mon Sep 17 00:00:00 2001 From: Matthew Mckee Date: Wed, 3 Dec 2025 19:27:46 +0000 Subject: [PATCH 2/5] Update builtin fixture docs --- docs/fixtures/builtin.md | 41 +++++++++++++++++++++++++++++++++++++++ docs/fixtures/fixtures.md | 41 +-------------------------------------- 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/docs/fixtures/builtin.md b/docs/fixtures/builtin.md index e69de29b..824acc9d 100644 --- a/docs/fixtures/builtin.md +++ b/docs/fixtures/builtin.md @@ -0,0 +1,41 @@ +Karva provides a few built-in fixtures that can be used in your tests. + +We will try to add more built-in fixtures from pytest in the future. + +## Temporary Directory + +This fixture provides the user with a `pathlib.Path` object that points to a temporary directory. + +You can use any of the following fixture names: + +- `tmp_path` (from pytest) +- `tmpdir` (from pytest) +- `temp_path` (from karva) +- `temp_dir` (from karva) + +```py title="test.py" +def test_tmp_path(tmp_path): + assert tmp_path.is_dir() +``` + +## Mock Environment + +This fixture allows you to safely modify environment variables, and the system path during tests. All changes are automatically undone after the test completes. + +You can use any of the following fixture names: + +- `monkeypatch` (from pytest) + +This fixture is compatible with pytest's `monkeypatch` fixture. + +```py title="test.py" +def test_setattr(monkeypatch): + import os + monkeypatch.setattr(os, 'getcwd', lambda: '/fake/path') + assert os.getcwd() == '/fake/path' + +def test_setenv(monkeypatch): + monkeypatch.setenv('MY_VAR', 'test_value') + import os + assert os.environ['MY_VAR'] == 'test_value' +``` diff --git a/docs/fixtures/fixtures.md b/docs/fixtures/fixtures.md index 7ebea067..2d5ba38b 100644 --- a/docs/fixtures/fixtures.md +++ b/docs/fixtures/fixtures.md @@ -1,8 +1,4 @@ -## Constraints - -We only discover package level fixtures from a `conftest.py` file in the root of that package. - -## Fixture Types +## Fixture Scopes Karva supports different types of fixtures based on their scope: @@ -225,38 +221,3 @@ In future you will be able to access other parameters. It is important to note that this request object is not the same as the pytest `FixtureRequest` object. It is a custom object provided by Karva. And so it may not have all of the information that the pytest `FixtureRequest` object has. - -## Built-in fixtures - -Karva provides a few built-in fixtures that can be used in your tests. - -We will try to add more built-in fixtures from pytest in the future. - -### Temporary Directory - -This fixture provides the user with a `pathlib.Path` object that points to a temporary directory. - -You can use any of the following fixture names to use this fixture: - -- `tmp_path` (from pytest) -- `tmpdir` (from pytest) -- `temp_path` (from karva) -- `temp_dir` (from karva) - -### Monkeypatch - -The `monkeypatch` fixture allows you to safely modify objects, dictionaries, environment variables, and the system path during tests. All changes are automatically undone after the test completes. - -This fixture is compatible with pytest's `monkeypatch` fixture. - -```py -def test_setattr(monkeypatch): - import os - monkeypatch.setattr(os, 'getcwd', lambda: '/fake/path') - assert os.getcwd() == '/fake/path' - -def test_setenv(monkeypatch): - monkeypatch.setenv('MY_VAR', 'test_value') - import os - assert os.environ['MY_VAR'] == 'test_value' -``` From 7b907c5e9323e342992cf7846e54be3f28cfea7c Mon Sep 17 00:00:00 2001 From: Matthew Mckee Date: Wed, 3 Dec 2025 19:29:56 +0000 Subject: [PATCH 3/5] Fix pre-commit --- docs/fixtures/builtin.md | 2 +- docs/fixtures/fixtures.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/fixtures/builtin.md b/docs/fixtures/builtin.md index 824acc9d..32fc0436 100644 --- a/docs/fixtures/builtin.md +++ b/docs/fixtures/builtin.md @@ -18,7 +18,7 @@ def test_tmp_path(tmp_path): assert tmp_path.is_dir() ``` -## Mock Environment +## Mock Environment This fixture allows you to safely modify environment variables, and the system path during tests. All changes are automatically undone after the test completes. diff --git a/docs/fixtures/fixtures.md b/docs/fixtures/fixtures.md index 2d5ba38b..96cb217d 100644 --- a/docs/fixtures/fixtures.md +++ b/docs/fixtures/fixtures.md @@ -1,4 +1,4 @@ -## Fixture Scopes +## Fixture Scopes Karva supports different types of fixtures based on their scope: From 0dd9a0ed11ec0c240b49fd67a21d52a7d219f884 Mon Sep 17 00:00:00 2001 From: Matthew Mckee Date: Wed, 3 Dec 2025 19:32:23 +0000 Subject: [PATCH 4/5] Update ci --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef427e3d..42220ce8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,6 +51,7 @@ jobs: ':!LICENSE' \ ':!pyproject.toml' \ ':!README.md' \ + ':!zensical.toml' \ ; then echo "changed=false" >> "$GITHUB_OUTPUT" else From 245515698b6237fa9744a48d38aea2566b6f234b Mon Sep 17 00:00:00 2001 From: Matthew Mckee Date: Wed, 3 Dec 2025 19:33:56 +0000 Subject: [PATCH 5/5] Update ci --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42220ce8..ee7af3fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,8 @@ jobs: MERGE_BASE: ${{ steps.merge_base.outputs.sha }} run: | if git diff --quiet "${MERGE_BASE}...HEAD" -- \ - ':!docs/**' \ + . \ + ':!docs/' \ ':!CODE_OF_CONDUCT.md' \ ':!CONTRIBUTING.md' \ ':!LICENSE' \ @@ -53,9 +54,9 @@ jobs: ':!README.md' \ ':!zensical.toml' \ ; then - echo "changed=false" >> "$GITHUB_OUTPUT" + echo "changed=false" >> "$GITHUB_OUTPUT" else - echo "changed=true" >> "$GITHUB_OUTPUT" + echo "changed=true" >> "$GITHUB_OUTPUT" fi pre-commit: