ADD: support for pylint.
This commit is contained in:
@@ -3,3 +3,4 @@ if test "$python_major_version" = "2" ; then
|
||||
pip install 'django<2'
|
||||
fi
|
||||
pip install -r requirements.txt
|
||||
pip install pylint
|
||||
|
||||
1
.buildbot/test/70-pylint.sh
Normal file
1
.buildbot/test/70-pylint.sh
Normal file
@@ -0,0 +1 @@
|
||||
pylint apps.base
|
||||
25
.pylintrc
Normal file
25
.pylintrc
Normal file
@@ -0,0 +1,25 @@
|
||||
[MASTER]
|
||||
|
||||
load-plugins=pylint_django
|
||||
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
|
||||
disable=missing-module-docstring,
|
||||
missing-class-docstring,
|
||||
missing-function-docstring,
|
||||
useless-object-inheritance,
|
||||
|
||||
[BASIC]
|
||||
|
||||
good-names=_,
|
||||
c,
|
||||
d,
|
||||
e,
|
||||
i,
|
||||
j,
|
||||
k,
|
||||
|
||||
[FORMAT]
|
||||
|
||||
max-line-length=120
|
||||
@@ -6,7 +6,7 @@ from django.test import SimpleTestCase
|
||||
|
||||
|
||||
class BaseTemplateTestCase(SimpleTestCase):
|
||||
def assertInHTML_multi(self, response, needles, format_kwargs=None):
|
||||
def assertInHTMLMulti(self, response, needles, format_kwargs=None): # pylint: disable=invalid-name
|
||||
content = response.content.decode('utf-8')
|
||||
for needle in needles:
|
||||
if format_kwargs is not None:
|
||||
@@ -35,7 +35,7 @@ class BaseTemplateTestCase(SimpleTestCase):
|
||||
'<link type="text/css" href="{static_url}{base_prefix}css/local.css" rel="stylesheet" />',
|
||||
)
|
||||
|
||||
self.assertInHTML_multi(response, needles, format_kwargs)
|
||||
self.assertInHTMLMulti(response, needles, format_kwargs)
|
||||
|
||||
def test_bootstrap_css_links(self):
|
||||
response = self.response
|
||||
@@ -55,7 +55,7 @@ class BaseTemplateTestCase(SimpleTestCase):
|
||||
'<script type="text/javascript" src="{static_url}{base_prefix}bootstrap/js/bootstrap.min.js"></script>',
|
||||
)
|
||||
|
||||
self.assertInHTML_multi(response, needles, format_kwargs)
|
||||
self.assertInHTMLMulti(response, needles, format_kwargs)
|
||||
|
||||
def test_page_footer(self):
|
||||
response = self.response
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import datetime
|
||||
import mock
|
||||
import re
|
||||
import socket
|
||||
import unittest
|
||||
import mock
|
||||
from django.test import SimpleTestCase
|
||||
|
||||
from ..views import RootView
|
||||
@@ -39,20 +39,20 @@ class RootUnitTestCase(unittest.TestCase):
|
||||
expected_color_hex = default_color_hex
|
||||
|
||||
with mock.patch('socket.gethostname', return_value=hostname):
|
||||
v = RootView()
|
||||
view = RootView()
|
||||
if 'kwargs' in test_data:
|
||||
c = v.get_context_data(**test_data['kwargs'])
|
||||
ctx = view.get_context_data(**test_data['kwargs'])
|
||||
else:
|
||||
c = v.get_context_data()
|
||||
ctx = view.get_context_data()
|
||||
|
||||
self.assertIsInstance(c, dict)
|
||||
self.assertIn('hostname', c)
|
||||
self.assertEqual(c['hostname'], hostname)
|
||||
self.assertIn('color_hex', c)
|
||||
self.assertTrue(re.match('[0-9a-f]{6}', c['color_hex']))
|
||||
self.assertEqual(c['color_hex'], expected_color_hex)
|
||||
self.assertIn('time', c)
|
||||
self.assertIsInstance(c['time'], datetime.datetime)
|
||||
self.assertIsInstance(ctx, dict)
|
||||
self.assertIn('hostname', ctx)
|
||||
self.assertEqual(ctx['hostname'], hostname)
|
||||
self.assertIn('color_hex', ctx)
|
||||
self.assertTrue(re.match('[0-9a-f]{6}', ctx['color_hex']))
|
||||
self.assertEqual(ctx['color_hex'], expected_color_hex)
|
||||
self.assertIn('time', ctx)
|
||||
self.assertIsInstance(ctx['time'], datetime.datetime)
|
||||
|
||||
|
||||
class DjangoAdminDjangoTestCase(SimpleTestCase):
|
||||
@@ -80,5 +80,3 @@ class RootDjangoTestCase(SimpleTestCase):
|
||||
response = self.client.get('/')
|
||||
hostname = socket.gethostname().capitalize()
|
||||
self.assertContains(response, hostname)
|
||||
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import argparse
|
||||
import coverage
|
||||
import datetime
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import coverage
|
||||
|
||||
|
||||
class Command(object):
|
||||
class Command(object): # pylint: disable=too-few-public-methods
|
||||
default_browser = 'firefox'
|
||||
|
||||
@staticmethod
|
||||
@@ -64,9 +64,9 @@ class Command(object):
|
||||
sys.stdout.write('Report directory: {}\n'.format(report_dir))
|
||||
try:
|
||||
self._create_report(report_dir)
|
||||
except Exception as e1:
|
||||
except Exception as e:
|
||||
self._remove_report_directory(report_dir)
|
||||
raise e1
|
||||
raise e
|
||||
|
||||
exitval = self._show_report(report_dir)
|
||||
return exitval
|
||||
|
||||
Reference in New Issue
Block a user