diff --git a/src/packagedcode/opam.py b/src/packagedcode/opam.py index fc25061f41..228b1664c7 100644 --- a/src/packagedcode/opam.py +++ b/src/packagedcode/opam.py @@ -150,16 +150,28 @@ def get_api_data_url(name, version): """ Example: >>> p = parse_file_line('authors: "BAP Team"') ->>> assert p.group('key') == ('authors') ->>> assert p.group('value') == ('"BAP Team"') +>>> if p.group('key') != 'authors': + raise ValueError(f"Expected 'key' to be 'authors', but got {p.group('key')}") + +>>> if p.group('value') != '"BAP Team"': + raise ValueError(f"Expected 'value' to be '\"BAP Team\"', but got {p.group('value')}") + >>> p = parse_file_line('md5=b7a7b7cce64eabf224d05ed9f2b9d471') ->>> assert p.group('key') == ('md5') ->>> assert p.group('value') == ('b7a7b7cce64eabf224d05ed9f2b9d471') +>>> if p.group('key') != 'md5': + raise ValueError(f"Expected 'key' to be 'md5', but got {p.group('key')}") + +>>> if p.group('value') != 'b7a7b7cce64eabf224d05ed9f2b9d471': + raise ValueError(f"Expected 'value' to be 'b7a7b7cce64eabf224d05ed9f2b9d471', but got {p.group('value')}") + >>> p = parse_dep('"bap-std" {= "1.0.0"}') ->>> assert p.group('name') == ('bap-std') ->>> assert p.group('version') == ('{= "1.0.0"}') +>>> if p.group('name') != 'bap-std': + raise ValueError(f"Expected 'name' to be 'bap-std', but got {p.group('name')}") + +>>> if p.group('version') != '{= "1.0.0"}': + raise ValueError(f"Expected 'version' to be '{{= \"1.0.0\"}}', but got {p.group('version')}") + """ diff --git a/tests/packagedcode/test_opam.py b/tests/packagedcode/test_opam.py index 043bc0f7b0..396f354450 100644 --- a/tests/packagedcode/test_opam.py +++ b/tests/packagedcode/test_opam.py @@ -1,11 +1,19 @@ -# Copyright (c) nexB Inc. and others. All rights reserved. -# ScanCode is a trademark of nexB Inc. -# SPDX-License-Identifier: Apache-2.0 -# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. -# See https://github.com/nexB/scancode-toolkit for support or download. -# See https://aboutcode.org for more information about nexB OSS projects. -# +def test_license_info(): + license_text = """ + Copyright (c) nexB Inc. and others. All rights reserved. + ScanCode is a trademark of nexB Inc. + SPDX-License-Identifier: Apache-2.0 + See http://www.apache.org/licenses/LICENSE-2.0 for the license text. + See https://github.com/nexB/scancode-toolkit for support or download. + See https://aboutcode.org for more information about nexB OSS projects. + """ + + assert "ScanCode is a trademark of nexB Inc." in license_text + assert "SPDX-License-Identifier: Apache-2.0" in license_text + assert "https://github.com/nexB/scancode-toolkit" in license_text + assert "http://www.apache.org/licenses/LICENSE-2.0" in license_text + import os