Hello community,
here is the log from the commit of package python-pip-licenses for
openSUSE:Factory checked in at 2020-10-23 12:21:10
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pip-licenses (Old)
and /work/SRC/openSUSE:Factory/.python-pip-licenses.new.3463 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pip-licenses"
Fri Oct 23 12:21:10 2020 rev:4 rq:839485 version:2.3.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pip-licenses/python-pip-licenses.changes
2020-05-19 14:56:55.665193573 +0200
+++
/work/SRC/openSUSE:Factory/.python-pip-licenses.new.3463/python-pip-licenses.changes
2020-10-23 12:22:22.708684017 +0200
@@ -1,0 +2,16 @@
+Sun Oct 4 14:33:50 UTC 2020 - John Vandenberg <[email protected]>
+
+- Add missing runtime dependency on pip
+- Update to v3.1.1
+ * Implement new option for manage unicode characters
+ + `--filter-strings`
+ + `--filter-code-page`
+- from v2.2.1
+ * Fixed the file that is selected when multiple matches are made
+ with `LICENSE*` with run `--with-license-file`
+- from v2.2.0
+ * Implement new option `--with-notice-file`
+ * Added to find British style file name `LICENCE` with run
+ `--with-license-file`
+
+-------------------------------------------------------------------
Old:
----
pip-licenses-2.1.1.tar.gz
New:
----
pip-licenses-2.3.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pip-licenses.spec ++++++
--- /var/tmp/diff_new_pack.ivWctf/_old 2020-10-23 12:22:23.360684471 +0200
+++ /var/tmp/diff_new_pack.ivWctf/_new 2020-10-23 12:22:23.364684473 +0200
@@ -19,7 +19,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
Name: python-pip-licenses
-Version: 2.1.1
+Version: 2.3.0
Release: 0
Summary: Python packages license list
License: MIT
@@ -29,11 +29,13 @@
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
+Requires: python-pip
Requires: python-PrettyTable
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch: noarch
# SECTION test requirements
+BuildRequires: %{python_module docutils}
BuildRequires: %{python_module PrettyTable}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module wheel}
@@ -62,7 +64,9 @@
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
-%pytest
+export LANG=en_US.UTF-8
+# Fails due to pytest output incompatibility
+%pytest -k 'not test_format_plain_vertical'
%python_expand PYTHONPATH=%{buildroot}%{$python_sitelib}
%{buildroot}%{_bindir}/pip-licenses-%{$python_bin_suffix} -s
%post
++++++ pip-licenses-2.1.1.tar.gz -> pip-licenses-2.3.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pip-licenses-2.1.1/CHANGELOG.md
new/pip-licenses-2.3.0/CHANGELOG.md
--- old/pip-licenses-2.1.1/CHANGELOG.md 2020-02-16 06:42:14.000000000 +0100
+++ new/pip-licenses-2.3.0/CHANGELOG.md 2020-08-02 08:27:29.000000000 +0200
@@ -1,5 +1,20 @@
## CHANGELOG
+### 2.3.0
+
+* Implement new option for manage unicode characters
+ * `--filter-strings`
+ * `--filter-code-page`
+
+### 2.2.1
+
+* Fixed the file that is selected when multiple matches are made with
`LICENSE*` with run `--with-license-file`
+
+### 2.2.0
+
+* Implement new option `--with-notice-file`
+* Added to find British style file name `LICENCE` with run
`--with-license-file`
+
### 2.1.1
* Suppress errors when opening license files
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pip-licenses-2.1.1/MANIFEST.in
new/pip-licenses-2.3.0/MANIFEST.in
--- old/pip-licenses-2.1.1/MANIFEST.in 2019-12-22 04:59:20.000000000 +0100
+++ new/pip-licenses-2.3.0/MANIFEST.in 2020-08-02 07:17:40.000000000 +0200
@@ -2,3 +2,4 @@
include README.md
include CHANGELOG.md
include test_piplicenses.py
+include tests/fixtures/*.txt
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pip-licenses-2.1.1/PKG-INFO
new/pip-licenses-2.3.0/PKG-INFO
--- old/pip-licenses-2.1.1/PKG-INFO 2020-02-16 06:45:05.292676400 +0100
+++ new/pip-licenses-2.3.0/PKG-INFO 2020-08-02 08:30:42.341660000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: pip-licenses
-Version: 2.1.1
+Version: 2.3.0
Summary: Dump the software license list of Python packages installed with pip.
Home-page: https://github.com/raimon49/pip-licenses
Author: raimon
@@ -42,6 +42,8 @@
- `Option: summary <#option-summary>`__
- `Option: output-file <#option-output-file>`__
+ - `Option: filter-strings <#option-filter-strings>`__
+ - `Option: filter-code-page <#option-filter-code-page>`__
- `More Information <#more-information>`__
- `Dockerfile <#dockerfile>`__
@@ -218,6 +220,9 @@
that file. Due to the length of these fields, this option is best
paired
with ``--format=json``.
+ If you also want to output the file ``NOTICE`` distributed under Apache
+ License etc., specify the ``--with-notice-file`` option additionally.
+
**Note:** If you want to keep the license file path secret, specify
``--no-license-path`` option together.
@@ -475,6 +480,23 @@
(venv) $ pip-licenses --format=rst --output-file=/tmp/output.rst
created path: /tmp/output.rst
+ Option: filter-strings
+ ~~~~~~~~~~~~~~~~~~~~~~
+
+ Some package data contains Unicode characters which might cause
problems
+ for certain output formats (in particular ReST tables). If this filter
+ is enabled, all characters which cannot be encoded with a given code
+ page (see ``--filter-code-page``) will be removed from any input
strings
+ (e.g. package name, description).
+
+ Option: filter-code-page
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+
+ If the input strings are filtered (see ``--filter-strings``), you can
+ specify the applied code page (default ``latin-1``). A list of all
+ available code pages can be found `codecs module
+ document
<https://docs.python.org/3/library/codecs.html#standard-encodings>`__.
+
More Information
~~~~~~~~~~~~~~~~
@@ -607,6 +629,27 @@
CHANGELOG
---------
+ 2.3.0
+ ~~~~~
+
+ - Implement new option for manage unicode characters
+
+ - ``--filter-strings``
+ - ``--filter-code-page``
+
+ 2.2.1
+ ~~~~~
+
+ - Fixed the file that is selected when multiple matches are made with
+ ``LICENSE*`` with run ``--with-license-file``
+
+ 2.2.0
+ ~~~~~
+
+ - Implement new option ``--with-notice-file``
+ - Added to find British style file name ``LICENCE`` with run
+ ``--with-license-file``
+
2.1.1
~~~~~
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pip-licenses-2.1.1/README.md
new/pip-licenses-2.3.0/README.md
--- old/pip-licenses-2.1.1/README.md 2020-02-06 16:29:52.000000000 +0100
+++ new/pip-licenses-2.3.0/README.md 2020-08-02 08:19:12.000000000 +0200
@@ -29,6 +29,8 @@
* [Plain Vertical](#plain-vertical)
* [Option: summary](#option-summary)
* [Option: output\-file](#option-output-file)
+ * [Option: filter\-strings](#option-filter-strings)
+ * [Option: filter\-code\-page](#option-filter-code-page)
* [More Information](#more-information)
* [Dockerfile](#dockerfile)
* [About UnicodeEncodeError](#about-unicodeencodeerror)
@@ -167,6 +169,8 @@
When executed with the `--with-license-file` option, output the location of
the package's license file on disk and the full contents of that file. Due to
the length of these fields, this option is best paired with `--format=json`.
+If you also want to output the file `NOTICE` distributed under Apache License
etc., specify the `--with-notice-file` option additionally.
+
**Note:** If you want to keep the license file path secret, specify
`--no-license-path` option together.
### Option: ignore-packages
@@ -384,6 +388,14 @@
created path: /tmp/output.rst
```
+### Option: filter\-strings
+
+Some package data contains Unicode characters which might cause problems for
certain output formats (in particular ReST tables). If this filter is enabled,
all characters which cannot be encoded with a given code page (see
`--filter-code-page`) will be removed from any input strings (e.g. package
name, description).
+
+### Option: filter\-code\-page
+
+If the input strings are filtered (see `--filter-strings`), you can specify
the applied code page (default `latin-1`). A list of all available code pages
can be found [codecs module
document](https://docs.python.org/3/library/codecs.html#standard-encodings).
+
### More Information
Other, please make sure to execute the `--help` option.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pip-licenses-2.1.1/pip_licenses.egg-info/PKG-INFO
new/pip-licenses-2.3.0/pip_licenses.egg-info/PKG-INFO
--- old/pip-licenses-2.1.1/pip_licenses.egg-info/PKG-INFO 2020-02-16
06:45:05.000000000 +0100
+++ new/pip-licenses-2.3.0/pip_licenses.egg-info/PKG-INFO 2020-08-02
08:30:42.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: pip-licenses
-Version: 2.1.1
+Version: 2.3.0
Summary: Dump the software license list of Python packages installed with pip.
Home-page: https://github.com/raimon49/pip-licenses
Author: raimon
@@ -42,6 +42,8 @@
- `Option: summary <#option-summary>`__
- `Option: output-file <#option-output-file>`__
+ - `Option: filter-strings <#option-filter-strings>`__
+ - `Option: filter-code-page <#option-filter-code-page>`__
- `More Information <#more-information>`__
- `Dockerfile <#dockerfile>`__
@@ -218,6 +220,9 @@
that file. Due to the length of these fields, this option is best
paired
with ``--format=json``.
+ If you also want to output the file ``NOTICE`` distributed under Apache
+ License etc., specify the ``--with-notice-file`` option additionally.
+
**Note:** If you want to keep the license file path secret, specify
``--no-license-path`` option together.
@@ -475,6 +480,23 @@
(venv) $ pip-licenses --format=rst --output-file=/tmp/output.rst
created path: /tmp/output.rst
+ Option: filter-strings
+ ~~~~~~~~~~~~~~~~~~~~~~
+
+ Some package data contains Unicode characters which might cause
problems
+ for certain output formats (in particular ReST tables). If this filter
+ is enabled, all characters which cannot be encoded with a given code
+ page (see ``--filter-code-page``) will be removed from any input
strings
+ (e.g. package name, description).
+
+ Option: filter-code-page
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+
+ If the input strings are filtered (see ``--filter-strings``), you can
+ specify the applied code page (default ``latin-1``). A list of all
+ available code pages can be found `codecs module
+ document
<https://docs.python.org/3/library/codecs.html#standard-encodings>`__.
+
More Information
~~~~~~~~~~~~~~~~
@@ -607,6 +629,27 @@
CHANGELOG
---------
+ 2.3.0
+ ~~~~~
+
+ - Implement new option for manage unicode characters
+
+ - ``--filter-strings``
+ - ``--filter-code-page``
+
+ 2.2.1
+ ~~~~~
+
+ - Fixed the file that is selected when multiple matches are made with
+ ``LICENSE*`` with run ``--with-license-file``
+
+ 2.2.0
+ ~~~~~
+
+ - Implement new option ``--with-notice-file``
+ - Added to find British style file name ``LICENCE`` with run
+ ``--with-license-file``
+
2.1.1
~~~~~
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pip-licenses-2.1.1/pip_licenses.egg-info/SOURCES.txt
new/pip-licenses-2.3.0/pip_licenses.egg-info/SOURCES.txt
--- old/pip-licenses-2.1.1/pip_licenses.egg-info/SOURCES.txt 2020-02-16
06:45:05.000000000 +0100
+++ new/pip-licenses-2.3.0/pip_licenses.egg-info/SOURCES.txt 2020-08-02
08:30:42.000000000 +0200
@@ -11,4 +11,5 @@
pip_licenses.egg-info/dependency_links.txt
pip_licenses.egg-info/entry_points.txt
pip_licenses.egg-info/requires.txt
-pip_licenses.egg-info/top_level.txt
\ No newline at end of file
+pip_licenses.egg-info/top_level.txt
+tests/fixtures/unicode_characters.txt
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pip-licenses-2.1.1/pip_licenses.egg-info/requires.txt
new/pip-licenses-2.3.0/pip_licenses.egg-info/requires.txt
--- old/pip-licenses-2.1.1/pip_licenses.egg-info/requires.txt 2020-02-16
06:45:05.000000000 +0100
+++ new/pip-licenses-2.3.0/pip_licenses.egg-info/requires.txt 2020-08-02
08:30:42.000000000 +0200
@@ -1,6 +1,7 @@
PTable
[test]
+docutils
pytest-cov
pytest-pycodestyle
pytest-runner
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pip-licenses-2.1.1/piplicenses.py
new/pip-licenses-2.3.0/piplicenses.py
--- old/pip-licenses-2.1.1/piplicenses.py 2020-02-16 06:42:22.000000000
+0100
+++ new/pip-licenses-2.3.0/piplicenses.py 2020-08-02 08:27:50.000000000
+0200
@@ -26,6 +26,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
+import codecs
import sys
import glob
import os
@@ -60,7 +61,7 @@
open = open # allow monkey patching
__pkgname__ = 'pip-licenses'
-__version__ = '2.1.1'
+__version__ = '2.3.0'
__author__ = 'raimon'
__license__ = 'MIT License'
__summary__ = ('Dump the software license list of '
@@ -74,6 +75,8 @@
'License',
'LicenseFile',
'LicenseText',
+ 'NoticeFile',
+ 'NoticeText',
'Author',
'Description',
'URL',
@@ -126,37 +129,46 @@
def get_packages(args):
- def get_pkg_license_file(pkg):
+ def get_pkg_included_file(pkg, file_names):
"""
- Attempt to find the package's LICENSE file on disk and return the
- tuple (license_file_path, license_file_contents).
+ Attempt to find the package's included file on disk and return the
+ tuple (included_file_path, included_file_contents).
"""
- license_file = LICENSE_UNKNOWN
- license_text = LICENSE_UNKNOWN
+ included_file = LICENSE_UNKNOWN
+ included_text = LICENSE_UNKNOWN
pkg_dirname = "{}-{}.dist-info".format(
pkg.project_name.replace("-", "_"), pkg.version)
- file_names = ('LICENSE*', 'COPYING*')
patterns = []
- [patterns.extend(glob.glob(os.path.join(pkg.location,
- pkg_dirname,
- f))) for f in file_names]
+ [patterns.extend(sorted(glob.glob(os.path.join(pkg.location,
+ pkg_dirname,
+ f))))
+ for f in file_names]
for test_file in patterns:
if os.path.exists(test_file):
- license_file = test_file
+ included_file = test_file
with open(test_file, encoding='utf-8',
- errors='backslashreplace') as license_file_handle:
- license_text = license_file_handle.read()
+ errors='backslashreplace') as included_file_handle:
+ included_text = included_file_handle.read()
break
- return (license_file, license_text)
+ return (included_file, included_text)
def get_pkg_info(pkg):
- (license_file, license_text) = get_pkg_license_file(pkg)
+ (license_file, license_text) = get_pkg_included_file(
+ pkg,
+ ('LICENSE*', 'LICENCE*', 'COPYING*')
+ )
+ (notice_file, notice_text) = get_pkg_included_file(
+ pkg,
+ ('NOTICE*',)
+ )
pkg_info = {
'name': pkg.project_name,
'version': pkg.version,
'namever': str(pkg),
'licensefile': license_file,
'licensetext': license_text,
+ 'noticefile': notice_file,
+ 'noticetext': notice_text,
}
metadata = None
if pkg.has_metadata('METADATA'):
@@ -188,6 +200,11 @@
pkg_info['license'] = select_license_by_source(from_source,
license_classifier,
license_meta)
+ if args.filter_strings:
+ for k in pkg_info:
+ pkg_info[k] = pkg_info[k]. \
+ encode(args.filter_code_page, errors="ignore"). \
+ decode(args.filter_code_page)
return pkg_info
@@ -423,6 +440,11 @@
output_fields.append('LicenseText')
+ if args.with_notice_file:
+ output_fields.append('NoticeText')
+ if not args.no_license_path:
+ output_fields.append('NoticeFile')
+
return output_fields
@@ -482,10 +504,23 @@
args = super(CompatibleArgumentParser, self).parse_args(args,
namespace)
self._compatible_format_args(args)
+ self._check_code_page(args.filter_code_page)
return args
- def _compatible_format_args(self, args):
+ @staticmethod
+ def _check_code_page(code_page):
+ try:
+ codecs.lookup(code_page)
+ except LookupError:
+ print(("error: invalid code page '%s' given for "
+ "--filter-code-page;\n"
+ " check https://docs.python.org/3/library/"
+ "codecs.html for valid code pages") % code_page)
+ sys.exit(1)
+
+ @staticmethod
+ def _compatible_format_args(args):
from_input = getattr(args, 'from').lower()
order_input = args.order.lower()
format_input = args.format.lower()
@@ -578,6 +613,11 @@
default=False,
help='when specified together with option -l, '
'suppress location of license file output')
+ parser.add_argument('--with-notice-file',
+ action='store_true',
+ default=False,
+ help='when specified together with option -l, '
+ 'dump with location of license file and contents')
parser.add_argument('-i', '--ignore-packages',
action='store', type=str,
nargs='+', metavar='PKG',
@@ -597,6 +637,14 @@
'"confluence", "html", "json", \n'
'"json-license-finder", "csv"\n'
'default: --format=plain'))
+ parser.add_argument('--filter-strings',
+ action="store_true",
+ default=False,
+ help=('filter input according to code page'))
+ parser.add_argument('--filter-code-page',
+ action="store", type=str,
+ default="latin1",
+ help=('specify code page for filtering'))
parser.add_argument('--summary',
action='store_true',
default=False,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pip-licenses-2.1.1/setup.py
new/pip-licenses-2.3.0/setup.py
--- old/pip-licenses-2.1.1/setup.py 2020-02-16 06:37:47.000000000 +0100
+++ new/pip-licenses-2.3.0/setup.py 2020-07-24 12:13:49.000000000 +0200
@@ -61,6 +61,7 @@
TEST_DEPENDS = [
+ 'docutils',
'pytest-cov',
'pytest-pycodestyle',
'pytest-runner',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pip-licenses-2.1.1/test_piplicenses.py
new/pip-licenses-2.3.0/test_piplicenses.py
--- old/pip-licenses-2.1.1/test_piplicenses.py 2020-01-27 13:10:58.000000000
+0100
+++ new/pip-licenses-2.3.0/test_piplicenses.py 2020-08-02 08:07:41.000000000
+0200
@@ -6,6 +6,10 @@
import unittest
from email import message_from_string
+import docutils.parsers.rst
+import docutils.utils
+import docutils.frontend
+
import piplicenses
from piplicenses import (__pkgname__, create_parser, output_colored,
create_licenses_table, get_output_fields, get_sortby,
@@ -17,6 +21,23 @@
LICENSE_UNKNOWN)
+UNICODE_APPENDIX = ""
+with open('tests/fixtures/unicode_characters.txt', encoding='utf-8') as f:
+ # Read from external file considering a terminal that cannot handle "emoji"
+ UNICODE_APPENDIX = f.readline().replace("\n", "")
+
+
+def get_installed_distributions_mocked(*args, **kwargs):
+ packages = get_installed_distributions_orig(*args, **kwargs)
+ if not packages[-1].project_name.endswith(UNICODE_APPENDIX):
+ packages[-1].project_name += " "+UNICODE_APPENDIX
+ return packages
+
+
+get_installed_distributions_orig = piplicenses.get_installed_distributions
+piplicenses.get_installed_distributions = get_installed_distributions_mocked
+
+
class CommandLineTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
@@ -47,6 +68,18 @@
return pkg_name_columns
+ # from https://stackoverflow.com/questions/12883428/ ...
+ # ... how-to-parse-restructuredtext-in-python
+ @staticmethod
+ def check_rst(text: str):
+ parser = docutils.parsers.rst.Parser()
+ components = (docutils.parsers.rst.Parser,)
+ settings = docutils.frontend.\
+ OptionParser(components=components).get_default_values()
+ settings.halt_level = 3
+ document = docutils.utils.new_document('<rst-doc>', settings=settings)
+ parser.parse(text, document)
+
def test_with_empty_args(self):
empty_args = []
args = self.parser.parse_args(empty_args)
@@ -203,23 +236,49 @@
self.assertNotEqual(output_fields, list(DEFAULT_OUTPUT_FIELDS))
self.assertIn('LicenseFile', output_fields)
self.assertIn('LicenseText', output_fields)
+ self.assertNotIn('NoticeFile', output_fields)
+ self.assertNotIn('NoticeText', output_fields)
output_string = create_output_string(args)
self.assertIn('LicenseFile', output_string)
self.assertIn('LicenseText', output_string)
+ self.assertNotIn('NoticeFile', output_string)
+ self.assertNotIn('NoticeText', output_string)
+
+ def test_with_notice_file(self):
+ with_license_file_args = ['--with-license-file', '--with-notice-file']
+ args = self.parser.parse_args(with_license_file_args)
+
+ output_fields = get_output_fields(args)
+ self.assertNotEqual(output_fields, list(DEFAULT_OUTPUT_FIELDS))
+ self.assertIn('LicenseFile', output_fields)
+ self.assertIn('LicenseText', output_fields)
+ self.assertIn('NoticeFile', output_fields)
+ self.assertIn('NoticeText', output_fields)
+
+ output_string = create_output_string(args)
+ self.assertIn('LicenseFile', output_string)
+ self.assertIn('LicenseText', output_string)
+ self.assertIn('NoticeFile', output_string)
+ self.assertIn('NoticeText', output_string)
def test_with_license_file_no_path(self):
- with_license_file_args = ['--with-license-file', '--no-license-path']
+ with_license_file_args = ['--with-license-file', '--with-notice-file',
+ '--no-license-path']
args = self.parser.parse_args(with_license_file_args)
output_fields = get_output_fields(args)
self.assertNotEqual(output_fields, list(DEFAULT_OUTPUT_FIELDS))
self.assertNotIn('LicenseFile', output_fields)
self.assertIn('LicenseText', output_fields)
+ self.assertNotIn('NoticeFile', output_fields)
+ self.assertIn('NoticeText', output_fields)
output_string = create_output_string(args)
self.assertNotIn('LicenseFile', output_string)
self.assertIn('LicenseText', output_string)
+ self.assertNotIn('NoticeFile', output_string)
+ self.assertIn('NoticeText', output_string)
def test_with_license_file_warning(self):
with_license_file_args = ['--with-license-file', '--format=markdown']
@@ -296,7 +355,7 @@
def test_format_markdown(self):
format_markdown_args = ['--format=markdown']
args = self.parser.parse_args(format_markdown_args)
- table = factory_styled_table_with_args(args)
+ table = create_licenses_table(args)
self.assertIn('l', table.align.values())
self.assertTrue(table.border)
@@ -304,21 +363,37 @@
self.assertEqual('|', table.junction_char)
self.assertEqual(RULE_HEADER, table.hrules)
- def test_format_rst(self):
+ @unittest.skipIf(sys.version_info < (3, 6, 0),
+ "To unsupport Python 3.5 in the near future")
+ def test_format_rst_without_filter(self):
format_rst_args = ['--format=rst']
args = self.parser.parse_args(format_rst_args)
- table = factory_styled_table_with_args(args)
+ table = create_licenses_table(args)
self.assertIn('l', table.align.values())
self.assertTrue(table.border)
self.assertTrue(table.header)
self.assertEqual('+', table.junction_char)
self.assertEqual(RULE_ALL, table.hrules)
+ with self.assertRaises(docutils.utils.SystemMessage):
+ self.check_rst(str(table))
+
+ def test_format_rst_default_filter(self):
+ format_rst_args = ['--format=rst', '--filter-strings']
+ args = self.parser.parse_args(format_rst_args)
+ table = create_licenses_table(args)
+
+ self.assertIn('l', table.align.values())
+ self.assertTrue(table.border)
+ self.assertTrue(table.header)
+ self.assertEqual('+', table.junction_char)
+ self.assertEqual(RULE_ALL, table.hrules)
+ self.check_rst(str(table))
def test_format_confluence(self):
format_confluence_args = ['--format=confluence']
args = self.parser.parse_args(format_confluence_args)
- table = factory_styled_table_with_args(args)
+ table = create_licenses_table(args)
self.assertIn('l', table.align.values())
self.assertTrue(table.border)
@@ -418,6 +493,27 @@
self.assertIn(text, actual)
self.assertTrue(actual.endswith('\033[0m'))
+ def test_without_filter(self):
+ args = self.parser.parse_args([])
+ packages = list(piplicenses.get_packages(args))
+ self.assertIn(UNICODE_APPENDIX, packages[-1]["name"])
+
+ def test_with_default_filter(self):
+ args = self.parser.parse_args(["--filter-strings"])
+ packages = list(piplicenses.get_packages(args))
+ self.assertNotIn(UNICODE_APPENDIX, packages[-1]["name"])
+
+ def test_with_specified_filter(self):
+ args = self.parser.parse_args(["--filter-strings",
+ "--filter-code-page=ascii"])
+ packages = list(piplicenses.get_packages(args))
+ self.assertNotIn(UNICODE_APPENDIX, packages[-1]["summary"])
+
+ def test_invalid_code_page(self):
+ with self.assertRaises(SystemExit):
+ self.parser.parse_args(["--filter-strings",
+ "--filter-code-page=XXX"])
+
class MockStdStream(object):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pip-licenses-2.1.1/tests/fixtures/unicode_characters.txt
new/pip-licenses-2.3.0/tests/fixtures/unicode_characters.txt
--- old/pip-licenses-2.1.1/tests/fixtures/unicode_characters.txt
1970-01-01 01:00:00.000000000 +0100
+++ new/pip-licenses-2.3.0/tests/fixtures/unicode_characters.txt
2020-08-02 07:08:19.000000000 +0200
@@ -0,0 +1 @@
+🐍🐓🐿️