Skip to content

Commit 6d4d4a7

Browse files
authored
Fix test_console failure finding pipdeptree in other environments (#351)
When we are using pytest in packaging process, we may not get the `/usr/bin/pipdeptree` as we need. So, let's use the `PATH` env to get the binary instead. fix: #348 Signed-off-by: cunshunxia <[email protected]>
1 parent bf5a865 commit 6d4d4a7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ optional-dependencies.test = [
5050
"covdefaults>=2.3",
5151
"diff-cover>=8.0.1",
5252
"pytest>=7.4.3",
53+
"pytest-console-scripts>=1.4.1",
5354
"pytest-cov>=4.1",
5455
"pytest-mock>=3.12",
5556
"virtualenv<21,>=20.25",

tests/test_pipdeptree.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
from __future__ import annotations
22

33
import sys
4-
from pathlib import Path
54
from subprocess import check_call # noqa: S404
5+
from typing import TYPE_CHECKING
6+
7+
if TYPE_CHECKING:
8+
from pytest_console_scripts import ScriptRunner
69

710

811
def test_main() -> None:
912
check_call([sys.executable, "-m", "pipdeptree", "--help"])
1013

1114

12-
def test_console() -> None:
13-
check_call([Path(sys.executable).parent / "pipdeptree", "--help"])
15+
def test_console(script_runner: ScriptRunner) -> None:
16+
result = script_runner.run("pipdeptree", "--help")
17+
assert result.success

0 commit comments

Comments
 (0)