~ubuntu-core-dev/update-notifier/ubuntu

« back to all changes in this revision

Viewing changes to tests/test_pycodestyle.py

  • Committer: Balint Reczey
  • Date: 2020-06-11 18:46:02 UTC
  • Revision ID: balint.reczey@canonical.com-20200611184602-2rv1zan3xu723x2u
Moved to git at https://git.launchpad.net/update-notifier

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python3
2
 
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
3
 
 
4
 
import os
5
 
import subprocess
6
 
import unittest
7
 
 
8
 
# pycodestyle is overdoing it a bit IMO
9
 
IGNORE_PYCODESTYLE = "E265, W503"
10
 
IGNORE_FILES = (
11
 
)
12
 
 
13
 
 
14
 
class TestPyCodeStyleClean(unittest.TestCase):
15
 
    """ ensure that the tree is pycodestyle clean """
16
 
 
17
 
    def test_pycodestyle_clean(self):
18
 
        CURDIR = os.path.dirname(os.path.abspath(__file__))
19
 
        for dirpath, dirs, files in os.walk(os.path.join(CURDIR, "..")):
20
 
            for f in files:
21
 
                if os.path.splitext(f)[1] != ".py":
22
 
                    continue
23
 
                if f in IGNORE_FILES:
24
 
                    continue
25
 
                py_file = os.path.join(dirpath, f)
26
 
                if f == 'test_motd.py':
27
 
                    ret_code = subprocess.call(
28
 
                        ["pycodestyle",
29
 
                         "--ignore={0}".format(IGNORE_PYCODESTYLE + ", E501"),
30
 
                         py_file])
31
 
                else:
32
 
                    ret_code = subprocess.call(
33
 
                        ["pycodestyle",
34
 
                         "--ignore={0}".format(IGNORE_PYCODESTYLE),
35
 
                         py_file])
36
 
                self.assertEqual(0, ret_code)
37
 
 
38
 
 
39
 
if __name__ == "__main__":
40
 
    import logging
41
 
    logging.basicConfig(level=logging.DEBUG)
42
 
    unittest.main()