Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Commit 58bf180

Browse files
committed
PEP8 fixes for tests.py
1 parent 2dc6ce9 commit 58bf180

1 file changed

Lines changed: 28 additions & 16 deletions

File tree

test.py

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,40 @@
2424
from documentcloud.toolbox import DuplicateObjectError
2525
from documentcloud.toolbox import CredentialsFailedError
2626
from documentcloud.toolbox import CredentialsMissingError
27-
from documentcloud import Annotation, Document, Project, Section, Entity, Mention
27+
from documentcloud import Annotation, Document, Project
28+
from documentcloud import Section, Entity, Mention
2829

2930
#
3031
# Odds and ends
3132
#
3233

34+
3335
def get_random_string(length=6):
3436
"""
3537
Generate a random string of letters and numbers
3638
"""
3739
return six.u(''.join(
38-
random.choice(string.ascii_letters + string.digits)
39-
for i in range(length)
40+
random.choice(
41+
string.ascii_letters + string.digits
42+
) for i in range(length)
4043
))
4144

4245

4346
PANGRAMS = {
4447
'en': 'The quick brown fox jumps over the lazy dog.',
45-
'da': 'Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen Wolther spillede på xylofon.',
48+
'da': 'Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen \
49+
Wolther spillede på xylofon.',
4650
'de': 'Falsches Üben von Xylophonmusik quält jeden größeren Zwerg.',
4751
'el': 'Γαζέες καὶ μυρτιὲς δὲν θὰ βρῶ πιὰ στὸ χρυσαφὶ ξέφωτο.',
48-
'es': 'El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y frío, añoraba a su querido cachorro.',
49-
'fr': "Portez ce vieux whisky au juge blond qui fume sur son île intérieure, à côté de l'alcôve ovoïde, où les bûches se consument dans l'âtre, ce qui lui permet de penser à la cænogenèse de l'être dont il est question dans la cause ambiguë entendue à Moÿ, dans un capharnaüm qui, pense-t-il, diminue çà et là la qualité de son œuvre.",
50-
'ga': "D'fhuascail Íosa, Úrmhac na hÓighe Beannaithe, pór Éava agus Ádhaimh.",
52+
'es': 'El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y \
53+
frío, añoraba a su querido cachorro.',
54+
'fr': "Portez ce vieux whisky au juge blond qui fume sur son île \
55+
intérieure, à côté de l'alcôve ovoïde, où les bûches se consument dans \
56+
l'âtre, ce qui lui permet de penser à la cænogenèse de l'être dont il est \
57+
question dans la cause ambiguë entendue à Moÿ, dans un capharnaüm qui, pense-\
58+
t-il, diminue çà et là la qualité de son œuvre.",
59+
'ga': "D'fhuascail Íosa, Úrmhac na hÓighe Beannaithe, pór Éava \
60+
agus Ádhaimh.",
5161
'hu': 'Árvíztűrő tükörfúrógép.',
5262
'is': 'Kæmi ný öxi hér ykist þjófum nú bæði víl og ádrepa.',
5363
'jp': """'いろはにほへとちりぬるを
@@ -63,6 +73,7 @@ def get_random_string(length=6):
6373
# Tests
6474
#
6575

76+
6677
class BaseTest(unittest.TestCase):
6778
"""
6879
A base class for all of our tests.
@@ -76,7 +87,7 @@ def get_version(self):
7687
def get_editable_document(self, version):
7788
"""
7889
Return the slug of the Document set aside for testing
79-
this version of Python against.
90+
this version of Python against.
8091
8192
We have to set aside a different document for each version
8293
because Travis CI tests run concurrently and we don't want
@@ -94,7 +105,7 @@ def get_editable_document(self, version):
94105
def get_editable_project(self, version):
95106
"""
96107
Return the id of the Project set aside for testing
97-
this version of Python against.
108+
this version of Python against.
98109
99110
We have to set aside a different project for each version
100111
because Travis CI tests run concurrently and we don't want
@@ -116,7 +127,7 @@ def setUp(self):
116127
self.test_id = '74103-report-of-the-calpers-special-review'
117128
self.public_client = DocumentCloud()
118129
self.private_client = DocumentCloud(
119-
os.environ['DOCUMENTCLOUD_TEST_USERNAME'],
130+
os.environ['DOCUMENTCLOUD_TEST_USERNAME'],
120131
os.environ['DOCUMENTCLOUD_TEST_PASSWORD']
121132
)
122133
self.fake_client = DocumentCloud("John Doe", "TK")
@@ -327,7 +338,7 @@ def test_private_actions(self):
327338
# Test whether you can save an attribute with some weird encoding
328339
before_title = copy(obj.title)
329340
before_description = copy(obj.description)
330-
obj.title = random.choice(list(PANGRAMS.keys()))
341+
obj.title = random.choice(list(PANGRAMS.keys()))
331342
obj.description = random.choice(list(PANGRAMS.keys()))
332343
obj.put()
333344
obj.title = before_title
@@ -411,7 +422,8 @@ def test_private_actions(self):
411422
obj.delete()
412423

413424
# Upload everything in this directory.
414-
obj_list = self.private_client.documents.upload_directory('./',
425+
obj_list = self.private_client.documents.upload_directory(
426+
'./',
415427
source='Los Angeles Times',
416428
published_url='http://www.latimes.com',
417429
)
@@ -428,7 +440,7 @@ class ProjectTest(BaseTest):
428440
"""
429441
def test_all(self):
430442
"""
431-
Test an `all` request for a list of all projects belong to an
443+
Test an `all` request for a list of all projects belong to an
432444
authorized user.
433445
"""
434446
obj_list = self.private_client.projects.all()
@@ -472,7 +484,7 @@ def test_put(self):
472484
# Create random strings we will save to the editable attributes
473485
title = 'The Klee Report (%s)' % get_random_string()
474486
description = textwrap.dedent("""
475-
An independent probe into Sam Zell\'s purchase of Tribune Company by
487+
An independent probe into Sam Zell's purchase of Tribune Company by
476488
investigator Kenneth Klee. Released at the end of July 2010. (%s)
477489
""")
478490
description = description % get_random_string()
@@ -534,8 +546,8 @@ def test_create_and_delete(self):
534546
proj.delete()
535547
self.assertRaises(
536548
DoesNotExistError,
537-
self.private_client.projects.get,\
538-
proj.id
549+
self.private_client.projects.get,
550+
proj.id
539551
)
540552

541553
def test_get_or_create(self):

0 commit comments

Comments
 (0)