Skip to content
Myr

👷‍♂️ Ensure the `PYTHONPATH` is set properly when testing the tutorial scripts (#407)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Matthias Bach · committed by GitHub · parent 29bec40 · Browse files · 2 files+10 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−0 removed

  • tests:+10 added−0 removed

2 files+10 added−0 removed

modified:tests/test_tutorial/test_subcommands/test_tutorial001.py+5 added
1import os2import subprocess34import pytest5from typer.testing import CliRunner
78 unmodified lines
8485def test_scripts(mod):86 from docs_src.subcommands.tutorial001 import items, users8788 env = os.environ.copy()89 env["PYTHONPATH"] = ":".join(list(tutorial001.__path__))9091 for module in [mod, items, users]:92 result = subprocess.run(93 ["coverage", "run", module.__file__, "--help"],94 stdout=subprocess.PIPE,95 stderr=subprocess.PIPE,96 encoding="utf-8",97 env=env,98 )99 assert "Usage" in result.stdout
modified:tests/test_tutorial/test_subcommands/test_tutorial003.py+5 added
1import os2import subprocess34import pytest5from typer.testing import CliRunner
151 unmodified lines
157158def test_scripts(mod):159 from docs_src.subcommands.tutorial003 import items, lands, reigns, towns, users160161 env = os.environ.copy()162 env["PYTHONPATH"] = ":".join(list(tutorial003.__path__))163164 for module in [mod, items, lands, reigns, towns, users]:165 result = subprocess.run(166 ["coverage", "run", module.__file__, "--help"],167 stdout=subprocess.PIPE,168 stderr=subprocess.PIPE,169 encoding="utf-8",170 env=env,171 )172 assert "Usage" in result.stdout