Codebase list distro-info / 531b555
Check everything with pylint (not only errors) Benjamin Drung 7 years ago
5 changed file(s) with 39 addition(s) and 32 deletion(s). Raw diff Collapse all Expand all
4444 $(foreach python,$(shell pyversions -r && py3versions -r),cd python && $(python) setup.py test$(\n))
4545
4646 clean:
47 rm -rf debian-distro-info ubuntu-distro-info python/build python/*.egg-info
47 rm -rf debian-distro-info ubuntu-distro-info python/build python/*.egg-info python/.pylint.d
4848 find python -name '*.pyc' -delete
4949
5050 .PHONY: build clean install test test-commandline test-perl test-python
55 Build-Depends: debhelper (>= 9),
66 distro-info-data (>= 0.7~),
77 pylint,
8 pylint3,
89 python-all (>= 2.6.3-3~),
910 python-setuptools,
1011 python-unittest2,
0 [MESSAGES CONTROL]
1
2 # Disable the message, report, category or checker with the given id(s). You
3 # can either give multiple identifiers separated by comma (,) or put this
4 # option multiple times (only on the command line, not in the configuration
5 # file where it should appear only once).You can also use "--disable=all" to
6 # disable everything first and then reenable specific checks. For example, if
7 # you want to run only the similarities checker, you can use "--disable=all
8 # --enable=similarities". If you want to run only the classes checker, but have
9 # no Warning level messages displayed, use"--disable=all --enable=classes
10 # --disable=W"
11 disable=invalid-name,locally-disabled,missing-docstring
12
13
014 [FORMAT]
115
216 # Maximum number of characters on a single line.
3 max-line-length=80
17 max-line-length=99
418
5 # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
19 # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
620 # tab).
721 indent-string=' '
22
23 [SIMILARITIES]
24
25 # Minimum lines number of a similarity.
26 min-similarity-lines=11
0 # test_pylint.py - Run pylint in errors-only mode.
0 # test_pylint.py - Run pylint
11 #
22 # Copyright (C) 2010, Stefano Rivera <stefanor@debian.org>
3 # Copyright (C) 2017, Benjamin Drung <bdrung@debian.org>
34 #
45 # Permission to use, copy, modify, and/or distribute this software for any
56 # purpose with or without fee is hereby granted, provided that the above
1415 # PERFORMANCE OF THIS SOFTWARE.
1516
1617 import subprocess
18 import sys
1719
1820 import setup
1921 from distro_info_test import unittest
20
21 WHITELIST = []
2222
2323
2424 class PylintTestCase(unittest.TestCase):
2525 def test_pylint(self):
2626 "Test: Run pylint on Python source code"
27 files = ['distro_info.py']
27 files = setup.PACKAGES + [m + '.py' for m in setup.PY_MODULES] + ['setup.py']
2828 for script in setup.SCRIPTS:
2929 script_file = open(script, 'r')
3030 if 'python' in script_file.readline():
3131 files.append(script)
3232 script_file.close()
33 cmd = ['pylint', '--rcfile=distro_info_test/pylint.conf', '-E',
34 '--include-ids=y', '--'] + files
35 process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
33 if sys.version_info[0] == 3:
34 pylint_binary = 'pylint3'
35 else:
36 pylint_binary = 'pylint'
37 cmd = [pylint_binary, '--rcfile=distro_info_test/pylint.conf', '--reports=n', '--'] + files
38 process = subprocess.Popen(cmd, env={'PYLINTHOME': '.pylint.d'}, stdout=subprocess.PIPE,
3639 stderr=subprocess.PIPE, close_fds=True)
3740
3841 out, err = process.communicate()
39 if err != '':
40 raise unittest.SkipTest('pylint crashed :/')
41
42 filtered_out = []
43 detected_in = ''
44 for line in out.splitlines():
45 if line.startswith('************* '):
46 detected_in = line
47 continue
48
49 for reg_exp in WHITELIST:
50 if reg_exp.search(line):
51 break
52 else:
53 filtered_out.append(detected_in)
54 filtered_out.append(line)
55
56 self.assertEqual(filtered_out, [],
57 "pylint found errors.\n"
58 "Filtered Output:\n" + '\n'.join(filtered_out))
42 self.assertFalse(err, pylint_binary + ' crashed. Error output:\n' + err.decode())
43 self.assertFalse(out, pylint_binary + " found errors:\n" + out.decode())
55 from setuptools import setup
66
77
8 PACKAGES = ['distro_info_test']
9 PY_MODULES = ['distro_info']
810 SCRIPTS = [
911 'debian-distro-info',
1012 'ubuntu-distro-info',
2729 setup(
2830 name='distro-info',
2931 version=get_debian_version(),
30 py_modules=['distro_info'],
31 packages=['distro_info_test'],
32 py_modules=PY_MODULES,
33 packages=PACKAGES,
3234 test_suite='distro_info_test.discover',
3335 )