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

This commit is contained in:
Matthias Bach 2022-11-07 18:53:34 +01:00 committed by GitHub
parent 29bec40e89
commit 52f488d1b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -1,3 +1,4 @@
import os
import subprocess
import pytest
@ -84,11 +85,15 @@ def test_users_delete(app):
def test_scripts(mod):
from docs_src.subcommands.tutorial001 import items, users
env = os.environ.copy()
env["PYTHONPATH"] = ":".join(list(tutorial001.__path__))
for module in [mod, items, users]:
result = subprocess.run(
["coverage", "run", module.__file__, "--help"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
env=env,
)
assert "Usage" in result.stdout

View file

@ -1,3 +1,4 @@
import os
import subprocess
import pytest
@ -157,11 +158,15 @@ def test_lands_towns_burn(app):
def test_scripts(mod):
from docs_src.subcommands.tutorial003 import items, lands, reigns, towns, users
env = os.environ.copy()
env["PYTHONPATH"] = ":".join(list(tutorial003.__path__))
for module in [mod, items, lands, reigns, towns, users]:
result = subprocess.run(
["coverage", "run", module.__file__, "--help"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
env=env,
)
assert "Usage" in result.stdout