Skip to content

Commit

Permalink
👷‍♂️ Ensure the PYTHONPATH is set properly when testing the tutoria…
Browse files Browse the repository at this point in the history
…l scripts (fastapi#407)
  • Loading branch information
theMarix authored and alexreg committed Nov 15, 2022
1 parent 4deb9a3 commit c9dbc47
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/test_tutorial/test_subcommands/test_tutorial001.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess

import pytest
Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions tests/test_tutorial/test_subcommands/test_tutorial003.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import subprocess

import pytest
Expand Down Expand Up @@ -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

0 comments on commit c9dbc47

Please sign in to comment.