- Added denose.patch removing dependency on the nose package.
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Pygments?expand=0&rev=46
This commit is contained in:
parent
e45bac06ec
commit
acf8bec509
208
denose.patch
Normal file
208
denose.patch
Normal file
@ -0,0 +1,208 @@
|
||||
--- a/tests/run.py
|
||||
+++ b/tests/run.py
|
||||
@@ -16,18 +16,13 @@ from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
+import unittest
|
||||
|
||||
# only find tests in this directory
|
||||
if os.path.dirname(__file__):
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
||||
|
||||
-try:
|
||||
- import nose
|
||||
-except ImportError:
|
||||
- print('nose is required to run the Pygments test suite')
|
||||
- sys.exit(1)
|
||||
-
|
||||
# make sure the current source is first on sys.path
|
||||
sys.path.insert(0, '..')
|
||||
|
||||
@@ -47,4 +42,4 @@ else:
|
||||
print('Pygments test suite running (Python %s)...' % sys.version.split()[0],
|
||||
file=sys.stderr)
|
||||
|
||||
-nose.main()
|
||||
+unittest.main()
|
||||
--- a/tests/support.py
|
||||
+++ b/tests/support.py
|
||||
@@ -5,7 +5,7 @@ Support for Pygments tests
|
||||
|
||||
import os
|
||||
|
||||
-from nose import SkipTest
|
||||
+from unittest import SkipTest
|
||||
|
||||
|
||||
def location(mod_name):
|
||||
--- a/tests/test_cmdline.py
|
||||
+++ b/tests/test_cmdline.py
|
||||
@@ -143,7 +143,7 @@ class CmdLineTest(unittest.TestCase):
|
||||
|
||||
def test_h_opt(self):
|
||||
o = self.check_success('-h')
|
||||
- self.assertTrue('Usage:' in o)
|
||||
+ self.assertIn('Usage:', o)
|
||||
|
||||
def test_L_opt(self):
|
||||
o = self.check_success('-L')
|
||||
@@ -157,37 +157,37 @@ class CmdLineTest(unittest.TestCase):
|
||||
filename = TESTFILE
|
||||
o = self.check_success('-Ofull=1,linenos=true,foo=bar',
|
||||
'-fhtml', filename)
|
||||
- self.assertTrue('<html' in o)
|
||||
- self.assertTrue('class="linenos"' in o)
|
||||
+ self.assertIn('<html', o)
|
||||
+ self.assertIn('class="linenos"', o)
|
||||
|
||||
# "foobar" is invalid for a bool option
|
||||
e = self.check_failure('-Ostripnl=foobar', TESTFILE)
|
||||
- self.assertTrue('Error: Invalid value' in e)
|
||||
+ self.assertIn('Error: Invalid value', e)
|
||||
e = self.check_failure('-Ostripnl=foobar', '-lpy')
|
||||
- self.assertTrue('Error: Invalid value' in e)
|
||||
+ self.assertIn('Error: Invalid value', e)
|
||||
|
||||
def test_P_opt(self):
|
||||
filename = TESTFILE
|
||||
o = self.check_success('-Pfull', '-Ptitle=foo, bar=baz=,',
|
||||
'-fhtml', filename)
|
||||
- self.assertTrue('<title>foo, bar=baz=,</title>' in o)
|
||||
+ self.assertIn('<title>foo, bar=baz=,</title>', o)
|
||||
|
||||
def test_F_opt(self):
|
||||
filename = TESTFILE
|
||||
o = self.check_success('-Fhighlight:tokentype=Name.Blubb,'
|
||||
'names=TESTFILE filename',
|
||||
'-fhtml', filename)
|
||||
- self.assertTrue('<span class="n n-Blubb' in o)
|
||||
+ self.assertIn('<span class="n n-Blubb', o)
|
||||
|
||||
def test_H_opt(self):
|
||||
o = self.check_success('-H', 'formatter', 'html')
|
||||
- self.assertTrue('HTML' in o)
|
||||
+ self.assertIn('HTML', o)
|
||||
o = self.check_success('-H', 'lexer', 'python')
|
||||
- self.assertTrue('Python' in o)
|
||||
+ self.assertIn('Python', o)
|
||||
o = self.check_success('-H', 'filter', 'raiseonerror')
|
||||
- self.assertTrue('raiseonerror', o)
|
||||
+ self.assertIn('raiseonerror', o)
|
||||
e = self.check_failure('-H', 'lexer', 'foobar')
|
||||
- self.assertTrue('not found' in e)
|
||||
+ self.assertIn('not found', e)
|
||||
|
||||
def test_S_opt(self):
|
||||
o = self.check_success('-S', 'default', '-f', 'html', '-O', 'linenos=1')
|
||||
@@ -196,11 +196,11 @@ class CmdLineTest(unittest.TestCase):
|
||||
# every line is for a token class
|
||||
parts = line.split()
|
||||
self.assertTrue(parts[0].startswith('.'))
|
||||
- self.assertTrue(parts[1] == '{')
|
||||
+ self.assertEqual(parts[1], '{')
|
||||
if parts[0] != '.hll':
|
||||
- self.assertTrue(parts[-4] == '}')
|
||||
- self.assertTrue(parts[-3] == '/*')
|
||||
- self.assertTrue(parts[-1] == '*/')
|
||||
+ self.assertEqual(parts[-4], '}')
|
||||
+ self.assertEqual(parts[-3], '/*')
|
||||
+ self.assertEqual(parts[-1], '*/')
|
||||
self.check_failure('-S', 'default', '-f', 'foobar')
|
||||
|
||||
def test_N_opt(self):
|
||||
@@ -228,68 +228,69 @@ class CmdLineTest(unittest.TestCase):
|
||||
self.check_failure(*opts, code=2)
|
||||
|
||||
def test_errors(self):
|
||||
+ this_file_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
+ empty_file = os.path.join(this_file_dir, 'support/empty.py')
|
||||
+
|
||||
# input file not found
|
||||
e = self.check_failure('-lpython', 'nonexistent.py')
|
||||
- self.assertTrue('Error: cannot read infile' in e)
|
||||
- self.assertTrue('nonexistent.py' in e)
|
||||
+ self.assertIn('Error: cannot read infile', e)
|
||||
+ self.assertIn('nonexistent.py', e)
|
||||
|
||||
# lexer not found
|
||||
e = self.check_failure('-lfooo', TESTFILE)
|
||||
- self.assertTrue('Error: no lexer for alias' in e)
|
||||
+ self.assertIn('Error: no lexer for alias', e)
|
||||
|
||||
# cannot load .py file without load_from_file flag
|
||||
e = self.check_failure('-l', 'nonexistent.py', TESTFILE)
|
||||
- self.assertTrue('Error: no lexer for alias' in e)
|
||||
+ self.assertIn('Error: no lexer for alias', e)
|
||||
|
||||
# lexer file is missing/unreadable
|
||||
e = self.check_failure('-l', 'nonexistent.py',
|
||||
'-x', TESTFILE)
|
||||
- self.assertTrue('Error: cannot read' in e)
|
||||
+ self.assertIn('Error: cannot read', e)
|
||||
|
||||
# lexer file is malformed
|
||||
- e = self.check_failure('-l', 'support/empty.py',
|
||||
- '-x', TESTFILE)
|
||||
- self.assertTrue('Error: no valid CustomLexer class found' in e)
|
||||
+ e = self.check_failure('-l', empty_file, '-x', TESTFILE)
|
||||
+ self.assertIn('Error: no valid CustomLexer class found', e)
|
||||
|
||||
# formatter not found
|
||||
e = self.check_failure('-lpython', '-ffoo', TESTFILE)
|
||||
- self.assertTrue('Error: no formatter found for name' in e)
|
||||
+ self.assertIn('Error: no formatter found for name', e)
|
||||
|
||||
# formatter for outfile not found
|
||||
e = self.check_failure('-ofoo.foo', TESTFILE)
|
||||
- self.assertTrue('Error: no formatter found for file name' in e)
|
||||
+ self.assertIn('Error: no formatter found for file name', e)
|
||||
|
||||
# cannot load .py file without load_from_file flag
|
||||
e = self.check_failure('-f', 'nonexistent.py', TESTFILE)
|
||||
- self.assertTrue('Error: no formatter found for name' in e)
|
||||
+ self.assertIn('Error: no formatter found for name', e)
|
||||
|
||||
# formatter file is missing/unreadable
|
||||
e = self.check_failure('-f', 'nonexistent.py',
|
||||
'-x', TESTFILE)
|
||||
- self.assertTrue('Error: cannot read' in e)
|
||||
+ self.assertIn('Error: cannot read', e)
|
||||
|
||||
# formatter file is malformed
|
||||
- e = self.check_failure('-f', 'support/empty.py',
|
||||
- '-x', TESTFILE)
|
||||
- self.assertTrue('Error: no valid CustomFormatter class found' in e)
|
||||
+ e = self.check_failure('-f', empty_file, '-x', TESTFILE)
|
||||
+ self.assertIn('Error: no valid CustomFormatter class found', e)
|
||||
|
||||
# output file not writable
|
||||
e = self.check_failure('-o', os.path.join('nonexistent', 'dir', 'out.html'),
|
||||
'-lpython', TESTFILE)
|
||||
- self.assertTrue('Error: cannot open outfile' in e)
|
||||
- self.assertTrue('out.html' in e)
|
||||
+ self.assertIn('Error: cannot open outfile', e)
|
||||
+ self.assertIn('out.html', e)
|
||||
|
||||
# unknown filter
|
||||
e = self.check_failure('-F', 'foo', TESTFILE)
|
||||
- self.assertTrue('Error: filter \'foo\' not found' in e)
|
||||
+ self.assertIn('Error: filter \'foo\' not found', e)
|
||||
|
||||
def test_exception(self):
|
||||
cmdline.highlight = None # override callable to provoke TypeError
|
||||
try:
|
||||
# unexpected exception while highlighting
|
||||
e = self.check_failure('-lpython', TESTFILE)
|
||||
- self.assertTrue('*** Error while highlighting:' in e)
|
||||
- self.assertTrue('TypeError' in e)
|
||||
+ self.assertIn('*** Error while highlighting:', e)
|
||||
+ self.assertIn('TypeError', e)
|
||||
|
||||
# same with -v: should reraise the exception
|
||||
try:
|
||||
--- /dev/null
|
||||
+++ b/tests/__init__.py
|
||||
@@ -0,0 +1 @@
|
||||
+
|
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Jan 10 01:20:08 UTC 2019 - Matej Cepl <mcepl@suse.com>
|
||||
|
||||
- Added denose.patch removing dependency on the nose package.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Dec 4 12:52:17 UTC 2018 - Matej Cepl <mcepl@suse.com>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-Pygments
|
||||
#
|
||||
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -26,8 +26,11 @@ Group: Development/Languages/Python
|
||||
URL: http://pygments.org
|
||||
Source: https://files.pythonhosted.org/packages/source/P/Pygments/Pygments-%{version}.tar.gz
|
||||
Patch0: python_37.diff
|
||||
BuildRequires: %{python_module nose}
|
||||
Patch1: denose.patch
|
||||
BuildRequires: %{python_module setuptools}
|
||||
# We need unittest2 just because of its test runner, it seems even
|
||||
# python3 stdlib unittest runner doesn't work
|
||||
BuildRequires: %{python_module pytest}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
Requires: python-setuptools
|
||||
@ -55,7 +58,7 @@ source code. Highlights are:
|
||||
|
||||
%prep
|
||||
%setup -q -n Pygments-%{version}
|
||||
%patch0 -p1
|
||||
%autopatch -p1
|
||||
# Remove non-oss licensed files, see bnc# 760344
|
||||
rm tests/examplefiles/{Sorting,test}.mod
|
||||
|
||||
@ -66,6 +69,7 @@ rm tests/examplefiles/{Sorting,test}.mod
|
||||
%python_install
|
||||
%{python_expand %$python_install
|
||||
mv %{buildroot}%{_bindir}/pygmentize %{buildroot}%{_bindir}/pygmentize-%{$python_bin_suffix}
|
||||
rm -rf %{buildroot}%{$python_sitelib}/tests
|
||||
%fdupes -s %{buildroot}%{$python_sitelib}
|
||||
%if "%{python3_bin_suffix}" != ""
|
||||
install -Dm0644 doc/pygmentize.1 %{buildroot}%{_mandir}/man1/pygmentize.1
|
||||
@ -81,8 +85,9 @@ install -Dm0644 doc/pygmentize.1 %{buildroot}%{_mandir}/man1/pygmentize.1
|
||||
%python_install_alternative pygmentize
|
||||
|
||||
%check
|
||||
export PYTHONDEBUG=1
|
||||
%python_exec tests/run.py
|
||||
# export PYTHONDEBUG=1
|
||||
export PYTHONPATH=tests
|
||||
%python_expand py.test-%{$python_bin_suffix} --disable-warnings -v tests
|
||||
|
||||
%files %{python_files}
|
||||
%license LICENSE
|
||||
|
Loading…
Reference in New Issue
Block a user