Working with module_globals
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- testing-qa
Research direction
Reproduce the failure from the issue's parametrized test using the docs/**/*.md examples and the module_globals passed to run_print_update and run_print_check. Trace those entry points to determine why datadir and foo are unavailable, then verify that both assertions pass in update and check modes.
Written by the indexing model from the issue text.
Description
So i tried to inject some fixtures as "module_globals" into my doctests, but I can't seem to get it to work.
I've tried the following:
from pathlib import Path
import pytest
from pytest_examples import CodeExample, EvalExample, find_examples
DOCS_DIR = Path(__file__).parent.parent / "docs"
DOCS_FILES = DOCS_DIR.glob("**/*.md")
@pytest.mark.parametrize("example", find_examples(*DOCS_FILES), ids=str)
def test_docs(
example: CodeExample,
eval_example: EvalExample,
datadir: Path,
):
"""Test the package's documentation."""
globals = dict(datadir=datadir, foo=2)
eval_example.set_config(line_length=88)
if eval_example.update_examples:
eval_example.format(example)
eval_example.run_print_update(example, module_globals=globals)
else:
eval_example.lint(example)
eval_example.run_print_check(example, module_globals=globals)
where my example Markdown file is picked up fine in the documentation directory, but the examples
assert datadir
and
assert foo == 2
both fail.
I can't find documentation on the feature, but would love to know how it's supposed to work!
- Dominant language
- Python
- Stars
- 181
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pydantic/pytest-examples
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pydantic/pytest-examples#87 ·
-
Clean up NeededPossibly taken @Danipulok claimed this 73 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
pydantic/pytest-examples#72 · 5 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
pydantic/pytest-examples#82 ·
-
Feature requrest [I can do it myself if allowed]: Allow configuration of `pytest-examples` from `pyproject.toml`Possibly taken @Danipulok claimed this 38 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 64/100
pydantic/pytest-examples#73 · 4 comments ·
-
target_versions are out of datePossibly taken @stevenh claimed this 507 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
pydantic/pytest-examples#63 · 1 comment ·
All issues in pydantic/pytest-examples
Similar issues
-
Email validation accepts a trailing newlinePossibly taken @marcello-pichini claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dbt-labs/spark-utils#51 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug frontend
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
vendrabuck/HERD#1419 ·
Maintainers usually reply within 1 day