FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

PEP 8: whitespace and blank lines · robquant/python-webuntis@0a13145 · GitHub

Commit 0a13145

Browse files
committed
PEP 8: whitespace and blank lines
1 parent a70e433 commit 0a13145

9 files changed

Lines changed: 70 additions & 52 deletions

File tree

‎setup.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
dependencies = ['requests']
1313

14-
if version_info < (2,6):
14+
if version_info < (2, 6):
1515
dependencies.append('simplejson')
1616

17-
if version_info < (2,7):
17+
if version_info < (2, 7):
1818
dependencies.append('ordereddict')
1919

2020
setup(

‎tests/__init__.py‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
:license: BSD, see LICENSE for more details.
66
"""
77

8-
98
import re
109
import unittest
1110
import mock
@@ -27,8 +26,8 @@
2726

2827

2928
def get_json_resource(name):
30-
with open(os.path.join(data_path, name)) as f:
31-
return json.load(f)
29+
with open(os.path.join(data_path, name)) as f:
30+
return json.load(f)
3231

3332

3433
class WebUntisTestCase(unittest.TestCase):
@@ -37,7 +36,7 @@ def cb(*args, **kwargs): # pragma: no cover
3736
raise Exception('These are offline tests.')
3837

3938
self.request_patcher = patcher = \
40-
mock.patch('webuntis.utils.remote._send_request', new=cb)
39+
mock.patch('webuntis.utils.remote._send_request', new=cb)
4140
patcher.start()
4241

4342
def tearDown(self):
@@ -64,7 +63,7 @@ def _assert_strict_equal_impl(self, x, y):
6463
return
6564
assert x == y
6665
assert issubclass(type(x), type(y)) or issubclass(type(y), type(x)), \
67-
'%s != %s' % (type(x), type(y))
66+
'%s != %s' % (type(x), type(y))
6867
if isinstance(x, (bytes, str)) or x is None:
6968
return
7069
elif isinstance(x, dict) or isinstance(y, dict):
@@ -81,7 +80,6 @@ def _assert_strict_equal_impl(self, x, y):
8180
assert repr(x) == repr(y), repr((x, y))[:200]
8281

8382

84-
8583
stub_session_parameters = {
8684
'useragent': 'fooagent',
8785
'school': 'fooschool',
@@ -98,7 +96,7 @@ def cb(*args, **kwargs): # pragma: no cover
9896
raise Exception('These are offline tests.')
9997

10098
self.request_patcher = patcher = \
101-
mock.patch('webuntis.utils.remote._send_request', new=cb)
99+
mock.patch('webuntis.utils.remote._send_request', new=cb)
102100
patcher.start()
103101

104102
self.session = webuntis.Session(**stub_session_parameters)
@@ -112,7 +110,6 @@ def tearDown(self):
112110

113111
self.session = None
114112

115-
116113

117114
def mock_results(methods, swallow_not_found=False):
118115
"""Mock API methods more easily.
@@ -124,6 +121,7 @@ def mock_results(methods, swallow_not_found=False):
124121
:param swallow_not_found: Whether to return {'result': {}} on unmocked API
125122
methods.
126123
"""
124+
127125
def new(url, jsondata, headers, http_session):
128126
method = jsondata['method']
129127
try:

‎tests/test_objects.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def test_repr(self):
4444
r1 = self.Result(data={u'id': 124}, session=object())
4545
assert repr(r1) == u"Result({u'id': 124})" or repr(r1) == u"Result({'id': 124})"
4646

47+
4748
class ListResultTests(WebUntisTestCase):
4849
Result = webuntis.objects.ListResult
4950
lazyproperty = webuntis.utils.misc.lazyproperty
@@ -81,7 +82,6 @@ class CustomListResult(self.Result):
8182
assert 'CustomListResult' in s
8283
assert 'CustomItem' in s
8384

84-
8585
def test_filter(self):
8686
class CustomItem(webuntis.objects.ListItem):
8787
@self.lazyproperty
@@ -302,8 +302,7 @@ def test_basics(self):
302302
data=1420202020202,
303303
session=object()
304304
)
305-
exp = datetime.datetime(2015, 1, 2, 13, 33, 40,tzinfo=None)
306-
305+
exp = datetime.datetime(2015, 1, 2, 13, 33, 40, tzinfo=None)
307306

308307
self.assertEqual(x.date.date(), exp.date())
309308
# some differences py2 vs. py3:
@@ -320,7 +319,7 @@ def test_basics(self):
320319
data=[{'day': 2, 'timeUnits': [{'startTime': 710, 'name': '0', 'endTime': 800},
321320
{'startTime': 800, 'name': '1', 'endTime': 850},
322321
{'startTime': 850, 'name': '2', 'endTime': 940}]}],
323-
session = object())
322+
session=object())
324323

325324
self.assertEqual(x[0].day, 2)
326325
self.assertEqual(x[0].dayname, "monday")

‎tests/test_session.py‎

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import mock
33
import webuntis
44
from . import WebUntisTestCase, stub_session_parameters, \
5-
mock_results
5+
mock_results
6+
67

78
class BasicUsage(WebUntisTestCase):
89
def test_login_repeat_not_logged_in(self):
@@ -11,9 +12,9 @@ def test_login_repeat_not_logged_in(self):
1112
calls = []
1213

1314
expected_calls = (
14-
['getCurrentSchoolyear', 'logout', 'authenticate']
15-
* (retry_amount + 1)
16-
)[:-2]
15+
['getCurrentSchoolyear', 'logout', 'authenticate']
16+
* (retry_amount + 1)
17+
)[:-2]
1718

1819
def authenticate(url, jsondata, headers):
1920
calls.append(jsondata['method'])
@@ -32,6 +33,7 @@ def logout(url, jsondata, headers):
3233
return {
3334
'result': {'bla': 'blub'} # shouldn't matter
3435
}
36+
3537
methods = {
3638
'authenticate': authenticate,
3739
'getCurrentSchoolyear': getCurrentSchoolyear,
@@ -40,8 +42,8 @@ def logout(url, jsondata, headers):
4042

4143
with mock_results(methods):
4244
with mock.patch.dict(
43-
s.config,
44-
{'login_repeat': retry_amount}
45+
s.config,
46+
{'login_repeat': retry_amount}
4547
):
4648
self.assertRaises(webuntis.errors.NotLoggedInError,
4749
s._request,
@@ -74,8 +76,8 @@ def test_login_successful(self):
7476
s = webuntis.Session(**session_params)
7577

7678
with mock.patch(
77-
'webuntis.Session._request',
78-
return_value={'sessionId': '123456'}
79+
'webuntis.Session._request',
80+
return_value={'sessionId': '123456'}
7981
) as mock_obj:
8082
s.login()
8183
assert s.config['jsessionid'] == '123456'
@@ -88,8 +90,8 @@ def test_login_no_response(self):
8890
s = webuntis.Session(**session_params)
8991

9092
with mock.patch(
91-
'webuntis.Session._request',
92-
return_value={}
93+
'webuntis.Session._request',
94+
return_value={}
9395
) as mock_obj:
9496
self.assertRaises(webuntis.errors.AuthError, s.login)
9597

@@ -104,8 +106,8 @@ def test_context_manager(self):
104106

105107
sessionid = 'foobar_session'
106108
with mock.patch(
107-
'webuntis.Session._request',
108-
return_value={'sessionId': sessionid}
109+
'webuntis.Session._request',
110+
return_value={'sessionId': sessionid}
109111
) as mock_obj:
110112
with s.login() as msg:
111113
assert mgr is s
@@ -115,11 +117,13 @@ def test_custom_cachelen(self):
115117
s = webuntis.Session(cachelen=20, **stub_session_parameters)
116118
assert s.cache._maxlen == 20
117119

120+
118121
class WrapperMethodTests(WebUntisTestCase):
119122
@staticmethod
120123
def noop_result_mock(methodname):
121124
def inner(url, jsondata, headers):
122125
return {'result': {}}
126+
123127
return mock_results({methodname: inner})
124128

125129
def test_departments(self):
@@ -138,6 +142,7 @@ def test_holidays(self):
138142

139143
def test_klassen(self):
140144
s = webuntis.Session(**stub_session_parameters)
145+
141146
def getKlassen(url, jsondata, headers):
142147
assert not jsondata['params']
143148
return {'result': {}}
@@ -150,6 +155,7 @@ def getKlassen(url, jsondata, headers):
150155
def test_klassen_with_schoolyear(self):
151156
s = webuntis.Session(**stub_session_parameters)
152157
yearid = 1232
158+
153159
def getKlassen(url, jsondata, headers):
154160
assert jsondata['params']['schoolyearId'] == yearid
155161
return {'result': {}}
@@ -163,19 +169,20 @@ def test_timetable(self):
163169
s = webuntis.Session(**stub_session_parameters)
164170

165171
startbase = 20120303
166-
endbase = 20120304
172+
endbase = 20120304
167173

168174
idbase = 12330
169175
for i, name in enumerate((
170-
'klasse',
171-
'teacher',
172-
'subject',
173-
'room',
174-
'student'
176+
'klasse',
177+
'teacher',
178+
'subject',
179+
'room',
180+
'student'
175181
), start=1):
176182
id = idbase + i
177183
start = startbase + i
178184
end = endbase + i
185+
179186
def getTimetable(url, jsondata, headers):
180187
assert jsondata['params']['type'] == i
181188
assert jsondata['params']['id'] == id
@@ -192,15 +199,15 @@ def getTimetable(url, jsondata, headers):
192199
def test_timetable_start_later_than_end(self):
193200
s = webuntis.Session(**stub_session_parameters)
194201
start = 20120308
195-
end = 20120303
202+
end = 20120303
196203

197204
self.assertRaisesRegex(ValueError, 'later', s.timetable,
198205
start=start, end=end, klasse=123)
199206

200207
def test_timetable_invalid_obj_given(self):
201208
s = webuntis.Session(**stub_session_parameters)
202209
start = 20120303
203-
end = 20120304
210+
end = 20120304
204211

205212
self.assertRaisesRegex(TypeError, 'by keyword', s.timetable,
206213
start=start, end=end)
@@ -255,9 +262,9 @@ def test_substitutions(self):
255262
def getSubstitutions(url, jsondata, headers):
256263
return {'result': []}
257264

258-
with mock_results({'getSubstitutions': getSubstitutions }):
265+
with mock_results({'getSubstitutions': getSubstitutions}):
259266
start = 20120303
260-
end = 20120304
267+
end = 20120304
261268
st = s.substitutions(start=start, end=end)
262269
assert type(st) is webuntis.objects.SubstitutionList
263270

‎tests/utils/test_misc.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@ def test_lazyproperty(self):
77
class FooBar(object):
88
obj = 42
99
_already_called = False
10+
1011
@webuntis.utils.misc.lazyproperty
1112
def yesplease(self):
1213
assert not self._already_called
1314
self._already_called = True
1415
return self.obj
15-
16+
1617
foobar = FooBar()
1718
assert foobar.yesplease == 42
1819
foobar.obj = 43
1920
assert foobar.yesplease == 42
2021

2122
def test_result_wrapper(self):
2223
wrapper = webuntis.utils.misc.result_wrapper
24+
2325
class PseudoSession(object):
2426
def __init__(self):
2527
self.cache = {}
@@ -67,6 +69,7 @@ def test_cache_key(self):
6769
assert hash(d) != hash(a)
6870
assert hash(d) != hash(c)
6971

72+
7073
class LruDictTests(WebUntisTestCase):
7174
def test_basic_interface(self):
7275
def test(Dict):
@@ -136,7 +139,7 @@ class FilterDictTests(WebUntisTestCase):
136139
def test_basics(self):
137140
d = webuntis.utils.misc.FilterDict({
138141
'foo': lambda x: 'whoopdeedoo',
139-
'bar': lambda x: 1/0,
142+
'bar': lambda x: 1 / 0,
140143
'alwaysnone': lambda x: None
141144
})
142145

‎tests/utils/test_remote.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from webuntis.utils.third_party import json
44
from .. import WebUntisTestCase, BytesIO
55

6+
67
class BasicUsage(WebUntisTestCase):
78
def test_parse_result(self):
89
x = webuntis.utils.remote._parse_result

‎tests/utils/test_timetable_utils.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
from webuntis.utils.timetable_utils import table
33
from .. import WebUntisTestCase
44

5+
56
class StubPeriod(object):
67
def __init__(self, start, end):
78
self.start = datetime.datetime.strptime(start, '%Y-%m-%d %H:%M')
89
self.end = datetime.datetime.strptime(end, '%Y-%m-%d %H:%M')
910

11+
1012
class BasicUsage(WebUntisTestCase):
1113
def test_empty(self):
1214
assert table([]) == []

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL