pep8 corrections

This commit is contained in:
Daniel Quinn 2016-10-26 09:32:59 +00:00
parent 63de2ca1b0
commit 8e58406881
4 changed files with 22 additions and 7 deletions

View File

@ -362,7 +362,8 @@ class Consumer(object):
def strip_excess_whitespace(text):
collapsed_spaces = re.sub(r"([^\S\r\n]+)", " ", text)
no_leading_whitespace = re.sub("([\n\r]+)([^\S\n\r]+)", '\\1', collapsed_spaces)
no_leading_whitespace = re.sub(
"([\n\r]+)([^\S\n\r]+)", '\\1', collapsed_spaces)
no_trailing_whitespace = re.sub("([^\S\n\r]+)$", '', no_leading_whitespace)
return no_trailing_whitespace

View File

@ -14,7 +14,7 @@ from dateutil import parser
from django.conf import settings
from .consumer import Consumer
from .models import Correspondent, Log
from .models import Correspondent
class MailFetcherError(Exception):

View File

@ -6,7 +6,6 @@ import time
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from ...models import Log
from ...consumer import Consumer, ConsumerError
from ...mail import MailFetcher, MailFetcherError

View File

@ -134,7 +134,7 @@ class TestAttributes(TestCase):
)
class Permutations(TestCase):
class TestFieldPermutations(TestCase):
valid_dates = (
"20150102030405Z",
@ -305,13 +305,28 @@ class Permutations(TestCase):
class TestOCR(TestCase):
text_cases = [
("simple string", "simple string"),
("simple newline\n testing string", "simple newline\ntesting string"),
("utf-8 строка с пробелами в конце ", "utf-8 строка с пробелами в конце")
(
"simple newline\n testing string",
"simple newline\ntesting string"
),
(
"utf-8 строка с пробелами в конце ",
"utf-8 строка с пробелами в конце"
)
]
def test_strip_excess_whitespace(self):
for source, result in self.text_cases:
actual_result = strip_excess_whitespace(source)
assert result == actual_result, "strip_exceess_whitespace(%s) != '%s', but '%s'" % (source, result, actual_result)
self.assertEqual(
result,
actual_result,
"strip_exceess_whitespace({}) != '{}', but '{}'".format(
source,
result,
actual_result
)
)