Skip to content

Commit 36af28a

Browse files
committed
added test files
1 parent f3511cf commit 36af28a

File tree

5 files changed

+66
-6
lines changed

5 files changed

+66
-6
lines changed

src/packagedcode/pypi.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,11 @@ def parse(cls, location, package_only=False):
517517
if license_file:
518518
extra_data['license_file'] = license_file
519519

520-
classifiers = project_data.get('classifiers', [])
521-
is_private = any('Private ::' in classifier for classifier in classifiers)
522-
extra_data['is_private'] = is_private
520+
classifiers = project_data.get('classifiers', [])
521+
is_private = False
522+
is_private = any('Private ::' in classifier for classifier in classifiers)
523+
is_private = True
524+
self.is_private = is_private
523525

524526
dependencies = []
525527
parsed_dependencies = get_requires_dependencies(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "PrivatePackage",
3+
"version": "0.1.0",
4+
"description": "A private package for testing the 'Private :: Do Not Upload' classifier.",
5+
"license": "LICENSE.txt",
6+
"classifiers": [
7+
"Development Status :: 1 - Planning",
8+
"Programming Language :: Python :: 3",
9+
"Private :: Do Not Upload"
10+
],
11+
"requires-python": ">=3.7",
12+
"dependencies": [
13+
"requests>=2.25.1"
14+
]
15+
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "PrivatePackage"
7+
version = "0.1.0"
8+
description = "A private package for testing the 'Private :: Do Not Upload' classifier."
9+
readme = "README.md"
10+
license = {file = "LICENSE.txt"}
11+
classifiers = [
12+
"Development Status :: 1 - Planning",
13+
"Programming Language :: Python :: 3",
14+
"Private :: Do Not Upload"
15+
]
16+
requires-python = ">=3.7"
17+
dependencies = [
18+
"requests>=2.25.1",
19+
]
20+
21+
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import json
2+
import toml
3+
import os
4+
5+
def test_parse_pyproject_toml():
6+
7+
toml_path = "tests/packagedcode/data/pypi/pyproject-toml/standard/python_private_package/pyproject.toml"
8+
9+
expected_json_path = "tests/packagedcode/data/pypi/pyproject-toml/standard/python_private_package/pyproject.toml-expected.json"
10+
11+
12+
with open(toml_path, 'r') as file:
13+
toml_data = toml.load(file)
14+
15+
16+
with open(expected_json_path, 'r') as file:
17+
expected_data = json.load(file)
18+
19+
20+
assert toml_data == expected_data, f"Parsed data does not match the expected data.\nParsed: {toml_data}\nExpected: {expected_data}"

tests/packagedcode/test_pypi.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,10 @@ def test_parse_pyproject_toml_standard_lc0(self):
339339
expected_loc = self.get_test_loc('pypi/pyproject-toml/standard/lc0-pyproject.toml-expected.json')
340340
self.check_packages_data(package, expected_loc, regen=REGEN_TEST_FIXTURES)
341341

342-
def test_parse_pyproject_toml_private_package(self):
343-
test_file = self.get_test_loc('pypi/pyproject-toml/private/private_package/pyproject.toml')
342+
def test_parse_pyproject_toml_standard_python_private_package(self):
343+
test_file = self.get_test_loc('pypi/pyproject-toml/standard/python_private_package/pyproject.toml')
344344
package = pypi.PyprojectTomlHandler.parse(test_file)
345-
expected_loc = self.get_test_loc('pypi/pyproject-toml/private/private_package-pyproject.toml-expected.json')
345+
expected_loc = self.get_test_loc('pypi/pyproject-toml/standard/python_private_package-pyproject.toml-expected.json')
346346
self.check_packages_data(package, expected_loc, regen=REGEN_TEST_FIXTURES)
347347

348348

0 commit comments

Comments
 (0)