Skip to content

Commit 829d2a5

Browse files
committed
Use absolute path to spawn test commands
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 998518f commit 829d2a5

File tree

2 files changed

+82
-43
lines changed

2 files changed

+82
-43
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"headers": {
3+
"tool_name": "python-inspector",
4+
"tool_homepageurl": "https://github.com/aboutcode-org/python-inspector",
5+
"options": [
6+
"--index-url https://pypi.org/simple",
7+
"--json <file>",
8+
"--operating-system linux",
9+
"--python-version 38",
10+
"--specifier zipp~=3.8.0"
11+
],
12+
"notice": "Dependency tree generated with python-inspector.\npython-inspector is a free software tool from nexB Inc. and others.\nVisit https://github.com/aboutcode-org/python-inspector/ for support and download.",
13+
"warnings": [],
14+
"errors": []
15+
},
16+
"files": [],
17+
"packages": [
18+
{
19+
"type": "pypi",
20+
"namespace": null,
21+
"name": "zipp",
22+
"version": "3.8.1",
23+
"qualifiers": {},
24+
"subpath": null,
25+
"primary_language": "Python",
26+
"description": "Backport of pathlib-compatible object wrapper for zip files\n.. image:: https://img.shields.io/pypi/v/zipp.svg\n :target: `PyPI link`_\n\n.. image:: https://img.shields.io/pypi/pyversions/zipp.svg\n :target: `PyPI link`_\n\n.. _PyPI link: https://pypi.org/project/zipp\n\n.. image:: https://github.com/jaraco/zipp/workflows/tests/badge.svg\n :target: https://github.com/jaraco/zipp/actions?query=workflow%3A%22tests%22\n :alt: tests\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n :target: https://github.com/psf/black\n :alt: Code style: Black\n\n.. .. image:: https://readthedocs.org/projects/skeleton/badge/?version=latest\n.. :target: https://skeleton.readthedocs.io/en/latest/?badge=latest\n\n.. image:: https://img.shields.io/badge/skeleton-2022-informational\n :target: https://blog.jaraco.com/skeleton\n\n.. image:: https://tidelift.com/badges/package/pypi/zipp\n :target: https://tidelift.com/subscription/pkg/pypi-zipp?utm_source=pypi-zipp&utm_medium=readme\n\n\nA pathlib-compatible Zipfile object wrapper. Official backport of the standard library\n`Path object <https://docs.python.org/3.8/library/zipfile.html#path-objects>`_.\n\n\nCompatibility\n=============\n\nNew features are introduced in this third-party library and later merged\ninto CPython. The following table indicates which versions of this library\nwere contributed to different versions in the standard library:\n\n.. list-table::\n :header-rows: 1\n\n * - zipp\n - stdlib\n * - 3.5\n - 3.11\n * - 3.3\n - 3.9\n * - 1.0\n - 3.8\n\n\nUsage\n=====\n\nUse ``zipp.Path`` in place of ``zipfile.Path`` on any Python.\n\nFor Enterprise\n==============\n\nAvailable as part of the Tidelift Subscription.\n\nThis project and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use.\n\n`Learn more <https://tidelift.com/subscription/pkg/pypi-zipp?utm_source=pypi-zipp&utm_medium=referral&utm_campaign=github>`_.\n\nSecurity Contact\n================\n\nTo report a security vulnerability, please use the\n`Tidelift security contact <https://tidelift.com/security>`_.\nTidelift will coordinate the fix and disclosure.",
27+
"release_date": "2022-07-12T14:21:20",
28+
"parties": [
29+
{
30+
"type": "person",
31+
"role": "author",
32+
"name": "Jason R. Coombs",
33+
"email": "jaraco@jaraco.com",
34+
"url": null
35+
}
36+
],
37+
"keywords": [
38+
"Development Status :: 5 - Production/Stable",
39+
"Intended Audience :: Developers",
40+
"Programming Language :: Python :: 3",
41+
"Programming Language :: Python :: 3 :: Only"
42+
],
43+
"homepage_url": "https://github.com/jaraco/zipp",
44+
"download_url": "https://files.pythonhosted.org/packages/f0/36/639d6742bcc3ffdce8b85c31d79fcfae7bb04b95f0e5c4c6f8b206a038cc/zipp-3.8.1-py3-none-any.whl",
45+
"size": 5645,
46+
"sha1": null,
47+
"md5": "300aa262796e7ebfb57b4d6731821c29",
48+
"sha256": "47c40d7fe183a6f21403a199b3e4192cca5774656965b0a4988ad2f8feb5f009",
49+
"sha512": null,
50+
"bug_tracking_url": null,
51+
"code_view_url": null,
52+
"vcs_url": null,
53+
"copyright": null,
54+
"license_expression": null,
55+
"declared_license": {
56+
"classifiers": [
57+
"License :: OSI Approved :: MIT License"
58+
]
59+
},
60+
"notice_text": null,
61+
"source_packages": [],
62+
"file_references": [],
63+
"extra_data": {},
64+
"dependencies": [],
65+
"repository_homepage_url": null,
66+
"repository_download_url": null,
67+
"api_data_url": "https://pypi.org/pypi/zipp/3.8.1/json",
68+
"datasource_id": null,
69+
"purl": "pkg:pypi/zipp@3.8.1"
70+
}
71+
],
72+
"resolved_dependencies_graph": [
73+
{
74+
"package": "pkg:pypi/zipp@3.8.1",
75+
"dependencies": []
76+
}
77+
]
78+
}

tests/test_cli.py

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def test_cli_with_single_env_var_index_url_except_pypi_simple():
228228

229229
@pytest.mark.online
230230
def test_cli_with_multiple_env_var_index_url_and_tilde_req():
231-
expected_file = test_env.get_test_loc("tilde_req-expected.json", must_exist=False)
231+
expected_file = test_env.get_test_loc("tilde_req-expected-env.json", must_exist=False)
232232
specifier = "zipp~=3.8.0"
233233
os.environ[
234234
"PYINSP_INDEX_URL"
@@ -702,9 +702,8 @@ def run_cli(
702702
if "--generic-paths" not in options:
703703
options.append("--generic-paths")
704704

705-
pyinsp_root_dir = dirname(dirname(__file__))
706-
707-
py_cmd = "python-inspector"
705+
root_dir = dirname(dirname(__file__))
706+
py_cmd = os.path.abspath(os.path.join(root_dir, "venv", "bin", "python-inspector"))
708707
rc, stdout, stderr = execute(
709708
cmd_loc=py_cmd,
710709
args=options,
@@ -716,7 +715,7 @@ def run_cli(
716715
time.sleep(1)
717716
if "--verbose" not in options:
718717
options.append("--verbose")
719-
result = rc, stdout, stderr = execute(
718+
rc, stdout, stderr = execute(
720719
cmd_loc=py_cmd,
721720
args=options,
722721
env=env,
@@ -742,41 +741,3 @@ def run_cli(
742741
def get_opts(options):
743742
opts = [o if isinstance(o, str) else repr(o) for o in options]
744743
return " ".join(opts)
745-
746-
747-
def run_click(
748-
options,
749-
cli=resolve_dependencies,
750-
expected_rc=0,
751-
env=None,
752-
get_env=True,
753-
):
754-
"""
755-
Run a command line resolution. Return a click.testing.Result object.
756-
"""
757-
758-
if not env:
759-
env = dict(os.environ)
760-
761-
runner = CliRunner()
762-
if get_env:
763-
options = append_os_and_pyver_options(options)
764-
765-
if "--generic-paths" not in options:
766-
options.append("--generic-paths")
767-
768-
result = runner.invoke(cli, options, catch_exceptions=False, env=env)
769-
770-
if result.exit_code != expected_rc:
771-
output = result.output
772-
opts = " ".join(options)
773-
if result.exit_code != expected_rc:
774-
error = f"""
775-
Failure to run:
776-
rc: {result.exit_code}
777-
python-inspector {opts}
778-
output:
779-
{output}
780-
"""
781-
assert result.exit_code == expected_rc, error
782-
return result

0 commit comments

Comments
 (0)