Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions tests/packagedcode/data/pypi/setup.py/with_name-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"type": "pypi",
"namespace": null,
"name": "arpy",
"version": "0.1.1",
"qualifiers": {},
"subpath": null,
"primary_language": "Python",
"description": "Library for accessing \"ar\" files",
"release_date": null,
"parties": [
{
"type": "person",
"role": "author",
"name": "Stanis\u0142aw Pitucha",
"email": "viraptor@gmail.com",
"url": "http://bitbucket.org/viraptor/arpy"
}
],
"keywords": [],
"homepage_url": "http://bitbucket.org/viraptor/arpy",
"download_url": null,
"size": null,
"sha1": null,
"md5": null,
"sha256": null,
"sha512": null,
"bug_tracking_url": null,
"code_view_url": null,
"vcs_url": null,
"copyright": null,
"license_expression": "bsd-simplified",
"declared_license": {
"license": "Simplified BSD",
"classifiers": []
},
"notice_text": null,
"root_path": null,
"dependencies": [],
"contains_source_code": null,
"source_packages": [],
"purl": "pkg:pypi/arpy@0.1.1",
"repository_homepage_url": "https://pypi.org/project/arpy",
"repository_download_url": "https://pypi.io/packages/source/a/arpy/arpy-0.1.1.tar.gz",
"api_data_url": "http://pypi.python.org/pypi/arpy/0.1.1/json"
}
15 changes: 15 additions & 0 deletions tests/packagedcode/data/pypi/setup.py/with_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from distutils.core import setup

setup(name='arpy',
version='0.1.1',
description='Library for accessing "ar" files',
author=u'Stanisław Pitucha',
author_email='viraptor@gmail.com',
url='http://bitbucket.org/viraptor/arpy',
py_modules=['arpy'],
license="Simplified BSD",
)

8 changes: 8 additions & 0 deletions tests/packagedcode/data/pypi/setup.py/without_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from setuptools import setup

setup(
version="1.0.0",
description="A sample package",
author="Test",
author_email="test@gmail.com",
package_requires=[])
13 changes: 13 additions & 0 deletions tests/packagedcode/test_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,19 @@ def test_parse_setup_py_xmltodict(self):
expected_loc = self.get_test_loc('pypi/setup.py/xmltodict_setup.py-expected.json')
self.check_package(package, expected_loc, regen=False)

def test_parse_setup_py_with_name(self):
test_file = self.get_test_loc('pypi/setup.py/with_name.py')
packages = pypi.parse_setup_py(test_file)
expected_loc = self.get_test_loc('pypi/setup.py/with_name.py.expected')
self.check_packages(packages, expected_loc, regen=False)

def test_parse_setup_py_without_name(self):
test_file = self.get_test_loc('pypi/setup.py/without_name.py')
try:
pypi.parse_setup_py(test_file)
except AttributeError as e:
assert "'NoneType' object has no attribute 'to_dict'" in str(e)
Comment on lines +237 to +238

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably be nicer to have a named exception for this or some custom logged error message so we know what exactly is wrong with the setup.py pypi package (in this case, a missing name field).


def test_pkginfo_parse_with_unpackaged_source(self):
test_file = self.get_test_loc('pypi')
package = pypi.parse_unpackaged_source(test_file)
Expand Down