Skip to content

Commit 6687b6f

Browse files
committed
Add more PyPI tests
Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent 40d6e1d commit 6687b6f

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"dependencies": [],
3+
"packages": [],
4+
"files": [
5+
{
6+
"path": "setup.py",
7+
"type": "file",
8+
"package_data": [
9+
{
10+
"type": "pypi",
11+
"namespace": null,
12+
"name": "pip",
13+
"version": "22.0.4",
14+
"qualifiers": {},
15+
"subpath": null,
16+
"primary_language": "Python",
17+
"description": "The PyPA recommended tool for installing Python packages.",
18+
"release_date": null,
19+
"parties": [
20+
{
21+
"type": "person",
22+
"role": "author",
23+
"name": "The pip developers",
24+
"email": "[email protected]",
25+
"url": null
26+
}
27+
],
28+
"keywords": [
29+
"Development Status :: 5 - Production/Stable",
30+
"Intended Audience :: Developers",
31+
"Topic :: Software Development :: Build Tools",
32+
"Programming Language :: Python",
33+
"Programming Language :: Python :: 3",
34+
"Programming Language :: Python :: 3 :: Only",
35+
"Programming Language :: Python :: 3.7",
36+
"Programming Language :: Python :: 3.8",
37+
"Programming Language :: Python :: 3.9",
38+
"Programming Language :: Python :: 3.10",
39+
"Programming Language :: Python :: Implementation :: CPython",
40+
"Programming Language :: Python :: Implementation :: PyPy"
41+
],
42+
"homepage_url": "https://pip.pypa.io/",
43+
"download_url": null,
44+
"size": null,
45+
"sha1": null,
46+
"md5": null,
47+
"sha256": null,
48+
"sha512": null,
49+
"bug_tracking_url": null,
50+
"code_view_url": "https://github.com/pypa/pip",
51+
"vcs_url": null,
52+
"copyright": null,
53+
"license_expression": null,
54+
"declared_license": {
55+
"license": "MIT",
56+
"classifiers": [
57+
"License :: OSI Approved :: MIT License"
58+
]
59+
},
60+
"notice_text": null,
61+
"source_packages": [],
62+
"file_references": [],
63+
"extra_data": {
64+
"Documentation": "https://pip.pypa.io",
65+
"Changelog": "https://pip.pypa.io/en/stable/news/",
66+
"python_requires": ">=3.7"
67+
},
68+
"dependencies": [],
69+
"repository_homepage_url": "https://pypi.org/project/pip",
70+
"repository_download_url": "https://pypi.org/packages/source/p/pip/pip-22.0.4.tar.gz",
71+
"api_data_url": "https://pypi.org/pypi/pip/22.0.4/json",
72+
"datasource_id": "pypi_setup_py",
73+
"purl": "pkg:pypi/[email protected]"
74+
}
75+
],
76+
"for_packages": [],
77+
"scan_errors": []
78+
}
79+
]
80+
}

tests/packagedcode/test_pypi.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ def test_package_scan_pypi_end_to_end(self):
3131
run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file])
3232
check_json_scan(expected_file, result_file, remove_uuid=True, regen=REGEN_TEST_FIXTURES)
3333

34+
def test_package_scan_pypi_setup_py_end_to_end(self):
35+
test_dir = self.get_test_loc('pypi/source-package/pip-22.0.4/setup.py')
36+
result_file = self.get_temp_file('json')
37+
expected_file = self.get_test_loc('pypi/source-package/pip-22.0.4-pypi-package-setup-expected.json', must_exist=False)
38+
run_scan_click(['--package', '--strip-root', '--processes', '-1', test_dir, '--json', result_file])
39+
check_json_scan(expected_file, result_file, remove_uuid=True, regen=REGEN_TEST_FIXTURES)
40+
3441
def test_package_scan_pypi_end_to_end_skip_site_packages(self):
3542
test_dir = self.get_test_loc('pypi/site-packages/codebase')
3643
result_file = self.get_temp_file('json')
@@ -45,6 +52,11 @@ def test_package_scan_pypi_end_to_end_can_handle_solo_setup_py(self):
4552
run_scan_click(['--package', '--processes', '-1', test_dir, '--json-pp', result_file])
4653
check_json_scan(expected_file, result_file, remove_uuid=True, regen=REGEN_TEST_FIXTURES)
4754

55+
def test_detect_version_attribute_setup_py(self):
56+
test_loc = self.get_test_loc('pypi/source-package/pip-22.0.4/setup.py')
57+
result = pypi.detect_version_attribute(test_loc)
58+
assert result == '22.0.4'
59+
4860

4961
class TestPyPiDevelopEggInfoPkgInfo(PackageTester):
5062
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')

0 commit comments

Comments
 (0)