-
-
Notifications
You must be signed in to change notification settings - Fork 834
Closed
Labels
questionQuestion or problemQuestion or problem
Description
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the Typer documentation, with the integrated search.
- I already searched in Google "How to X in Typer" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to Typer but to Click.
Commit to Help
- I commit to help with one of those options 👆
Example Code
from typer.testing import CliRunner
from .main import app
runner = CliRunner()
def test_list_databases() -> None:
# This command causes an internal 'databases' object to be cached.
result = runner.invoke(app, ["databases", "list"]
assert result.exit_code == 0
def test_create_database() -> None:
# This command accesses some cached properties (using cached-property package).
# Those objects aren't supposed to exist yet, but they were already created in previous tests.
# This causes the command to use old data and crash.
result = runner.invoke(app, ["databases", "create", "tests-db", "MariaDB"])
assert result.exit_code == 0Description
CliRunner.invoke reuses 'app' causing different behavior than just running them outside tests.
My code uses some cached properties that get cached in earlier tests.
This causes some commands to use old data, which causes it to crash.
Normally this would never happen as the program exits after a single command.
Operating System
Linux
Operating System Details
No response
Typer Version
0.4.0
Python Version
3.7
Additional Context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionQuestion or problemQuestion or problem