Skip to content

Commit

Permalink
Fix test_console failure finding pipdeptree in other environments (#351)
Browse files Browse the repository at this point in the history
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 <cunshunxia@tencent.com>
  • Loading branch information
xiacunshun committed Apr 13, 2024
1 parent bf5a865 commit 6d4d4a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ optional-dependencies.test = [
"covdefaults>=2.3",
"diff-cover>=8.0.1",
"pytest>=7.4.3",
"pytest-console-scripts>=1.4.1",
"pytest-cov>=4.1",
"pytest-mock>=3.12",
"virtualenv<21,>=20.25",
Expand Down
10 changes: 7 additions & 3 deletions tests/test_pipdeptree.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
from __future__ import annotations

import sys
from pathlib import Path
from subprocess import check_call # noqa: S404
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from pytest_console_scripts import ScriptRunner


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


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

0 comments on commit 6d4d4a7

Please sign in to comment.