Skip to content

Commit 4cd5453

Browse files
pep8 tests
1 parent 01bda16 commit 4cd5453

7 files changed

+74
-54
lines changed

bpython/test/test_autocomplete.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ def test_att_matches_found_on_old_style_instance(self):
250250
locals_={'a': OldStyleFoo()}),
251251
set(['a.method', 'a.a', 'a.b']))
252252
self.assertIn(u'a.__dict__',
253-
self.com.matches(4, 'a.__', locals_={'a': OldStyleFoo()}))
253+
self.com.matches(4, 'a.__',
254+
locals_={'a': OldStyleFoo()}))
254255

255256
@skip_old_style
256257
def test_att_matches_found_on_old_style_class_object(self):
@@ -274,7 +275,8 @@ def setUpClass(cls):
274275
cls.com = autocomplete.ExpressionAttributeCompletion()
275276

276277
def test_att_matches_found_on_instance(self):
277-
self.assertSetEqual(self.com.matches(5, 'a[0].', locals_={'a': [Foo()]}),
278+
self.assertSetEqual(self.com.matches(5, 'a[0].',
279+
locals_={'a': [Foo()]}),
278280
set(['method', 'a', 'b']))
279281

280282
@skip_old_style
@@ -297,7 +299,8 @@ def test_tuples_complete(self):
297299

298300
@unittest.skip('TODO, subclasses do not complete yet')
299301
def test_list_subclasses_complete(self):
300-
class ListSubclass(list): pass
302+
class ListSubclass(list):
303+
pass
301304
self.assertSetEqual(self.com.matches(5, 'a[0].',
302305
locals_={'a': ListSubclass([Foo()])}),
303306
set(['method', 'a', 'b']))
@@ -394,7 +397,7 @@ def test_completions_are_unicode(self):
394397
@unittest.skipIf(py3, "in Python 3 invalid identifiers are passed through")
395398
def test_ignores_nonascii_encodable(self):
396399
self.assertEqual(self.com.matches(3, 'abc', locals_={'abcß': 10}),
397-
None)
400+
None)
398401

399402
def test_mock_kwlist(self):
400403
with mock.patch.object(keyword, 'kwlist', new=['abcd']):

bpython/test/test_curtsies_painting.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def undo(self):
185185

186186
def setUp(self):
187187
self.refresh_requests = []
188+
188189
class TestRepl(BaseRepl):
189190
def _request_refresh(inner_self):
190191
self.refresh()
@@ -553,14 +554,14 @@ def test_unhighlight_paren_bugs(self):
553554
self.assertEqual(self.repl.rl_history.entries, [''])
554555
self.repl.process_event(')')
555556
self.assertEqual(self.repl.rl_history.entries, [''])
556-
screen = fsarray([cyan(">>> ")+on_magenta(bold(red('('))),
557-
green("... ")+on_magenta(bold(red(')')))])
557+
screen = fsarray([cyan(">>> ") + on_magenta(bold(red('('))),
558+
green("... ") + on_magenta(bold(red(')')))])
558559
self.assert_paint(screen, (1, 5))
559560

560561
with output_to_repl(self.repl):
561562
self.repl.process_event(' ')
562-
screen = fsarray([cyan(">>> ")+yellow('('),
563-
green("... ")+yellow(')')+bold(cyan(" "))])
563+
screen = fsarray([cyan(">>> ") + yellow('('),
564+
green("... ") + yellow(')') + bold(cyan(" "))])
564565
self.assert_paint(screen, (1, 6))
565566

566567
def send_key(self, key):

bpython/test/test_curtsies_repl.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from bpython import args
1919
from bpython._py3compat import py3
2020
from bpython.test import (FixLanguageTestCase as TestCase, MagicIterMock, mock,
21-
builtin_target, unittest)
21+
unittest)
2222

2323
from curtsies import events
2424

@@ -299,8 +299,8 @@ def setUp(self):
299299
self.open = partial(io.open, mode='wt', encoding='utf-8')
300300
self.dont_write_bytecode = sys.dont_write_bytecode
301301
sys.dont_write_bytecode = True
302-
self.sys_path = sys.path #?
303-
sys.path = self.sys_path[:] #?
302+
self.sys_path = sys.path
303+
sys.path = self.sys_path[:]
304304

305305
# Because these tests create Python source files at runtime,
306306
# it's possible in Python >=3.3 for the importlib.machinery.FileFinder
@@ -318,7 +318,7 @@ def setUp(self):
318318

319319
def tearDown(self):
320320
sys.dont_write_bytecode = self.dont_write_bytecode
321-
sys.path = self.sys_path #?
321+
sys.path = self.sys_path
322322

323323
def push(self, line):
324324
self.repl._current_line = line
@@ -358,21 +358,21 @@ def test_import_module_with_rewind(self):
358358
with self.open(fullpath) as f:
359359
f.write('a = 0\n')
360360
self.head(path)
361-
self.push('import %s' % (modname)) # SOMETIMES THIS MAKES THE OTHER TEST FAIL!!!
362-
#self.assertIn(modname, self.repl.interp.locals)
361+
self.push('import %s' % (modname))
362+
self.assertIn(modname, self.repl.interp.locals)
363363
self.repl.undo()
364-
#self.assertNotIn(modname, self.repl.interp.locals)
364+
self.assertNotIn(modname, self.repl.interp.locals)
365365
self.repl.clear_modules_and_reevaluate()
366-
#self.assertNotIn(modname, self.repl.interp.locals)
367-
#self.push('import %s' % (modname))
368-
#self.push('a = %s.a' % (modname))
369-
#self.assertIn('a', self.repl.interp.locals)
370-
#self.assertEqual(self.repl.interp.locals['a'], 0)
366+
self.assertNotIn(modname, self.repl.interp.locals)
367+
self.push('import %s' % (modname))
368+
self.push('a = %s.a' % (modname))
369+
self.assertIn('a', self.repl.interp.locals)
370+
self.assertEqual(self.repl.interp.locals['a'], 0)
371371
with self.open(fullpath) as f:
372372
f.write('a = 1\n')
373-
#self.repl.clear_modules_and_reevaluate()
374-
#self.assertIn('a', self.repl.interp.locals)
375-
#self.assertEqual(self.repl.interp.locals['a'], 1)
373+
self.repl.clear_modules_and_reevaluate()
374+
self.assertIn('a', self.repl.interp.locals)
375+
self.assertEqual(self.repl.interp.locals['a'], 1)
376376

377377

378378
class TestCurtsiesPagerText(TestCase):
@@ -443,7 +443,6 @@ def test_control_events_in_small_paste(self):
443443
self.repl.process_event(p)
444444
self.assertEqual(self.repl.current_line, 'eabcd')
445445

446-
447446
def test_control_events_in_large_paste(self):
448447
"""Large paste events should ignore control characters"""
449448
p = events.PasteEvent()

bpython/test/test_interpreter.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@ def append_to_a(message):
3232
i.runsource('1.1.1.1')
3333

3434
if pypy:
35-
expected = ' File ' + green('"%s"' % _last_console_filename()) + ', line ' + \
36-
bold(magenta('1')) + '\n 1.1.1.1\n ^\n' + \
37-
bold(red('SyntaxError')) + ': ' + cyan('invalid syntax') + '\n'
35+
expected = (
36+
' File ' + green('"%s"' % _last_console_filename()) +
37+
', line ' + bold(magenta('1')) + '\n 1.1.1.1\n ^\n' +
38+
bold(red('SyntaxError')) + ': ' + cyan('invalid syntax') +
39+
'\n')
3840
else:
39-
expected = ' File ' + green('"%s"' % _last_console_filename()) + ', line ' + \
40-
bold(magenta('1')) + '\n 1.1.1.1\n ^\n' + \
41-
bold(red('SyntaxError')) + ': ' + cyan('invalid syntax') + '\n'
41+
expected = (
42+
' File ' + green('"%s"' % _last_console_filename()) +
43+
', line ' + bold(magenta('1')) + '\n 1.1.1.1\n ^\n' +
44+
bold(red('SyntaxError')) + ': ' + cyan('invalid syntax') +
45+
'\n')
4246

4347
self.assertMultiLineEqual(str(plain('').join(a)), str(expected))
4448
self.assertEquals(plain('').join(a), expected)
@@ -65,10 +69,11 @@ def g():
6569
else:
6670
global_not_found = "name 'g' is not defined"
6771

68-
expected = 'Traceback (most recent call last):\n File ' + \
69-
green('"%s"' % _last_console_filename()) + ', line ' + bold(magenta('1')) + ', in ' + \
70-
cyan('<module>') + '\n g()\n' + bold(red('NameError')) + ': ' + \
71-
cyan(global_not_found) + '\n'
72+
expected = (
73+
'Traceback (most recent call last):\n File ' +
74+
green('"%s"' % _last_console_filename()) + ', line ' +
75+
bold(magenta('1')) + ', in ' + cyan('<module>') + '\n g()\n' +
76+
bold(red('NameError')) + ': ' + cyan(global_not_found) + '\n')
7277

7378
self.assertMultiLineEqual(str(plain('').join(a)), str(expected))
7479
self.assertEquals(plain('').join(a), expected)

bpython/test/test_manual_readline.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -203,19 +203,19 @@ def test_transpose_character_before_cursor(self):
203203

204204
def test_transpose_empty_line(self):
205205
self.assertEquals(transpose_character_before_cursor(0, ''),
206-
(0,''))
206+
(0, ''))
207207

208208
def test_transpose_first_character(self):
209209
self.assertEquals(transpose_character_before_cursor(0, 'a'),
210-
(0, 'a'))
210+
(0, 'a'))
211211
self.assertEquals(transpose_character_before_cursor(0, 'as'),
212-
(0, 'as'))
213-
212+
(0, 'as'))
213+
214214
def test_transpose_end_of_line(self):
215215
self.assertEquals(transpose_character_before_cursor(1, 'a'),
216-
(1, 'a'))
216+
(1, 'a'))
217217
self.assertEquals(transpose_character_before_cursor(2, 'as'),
218-
(2, 'sa'))
218+
(2, 'sa'))
219219

220220
def test_transpose_word_before_cursor(self):
221221
pass
@@ -245,7 +245,8 @@ def setUp(self):
245245
self.edits = UnconfiguredEdits()
246246

247247
def test_seq(self):
248-
f = lambda cursor_offset, line: ('hi', 2)
248+
def f(cursor_offset, line):
249+
return ('hi', 2)
249250
self.edits.add('a', f)
250251
self.assertIn('a', self.edits)
251252
self.assertEqual(self.edits['a'], f)
@@ -257,24 +258,33 @@ def test_seq(self):
257258
self.edits.call('b')
258259

259260
def test_functions_with_bad_signatures(self):
260-
f = lambda something: (1, 2)
261+
def f(something):
262+
return (1, 2)
261263
with self.assertRaises(TypeError):
262264
self.edits.add('a', f)
263-
g = lambda cursor_offset, line, something, something_else: (1, 2)
265+
266+
def g(cursor_offset, line, something, something_else):
267+
return (1, 2)
264268
with self.assertRaises(TypeError):
265269
self.edits.add('a', g)
266270

267271
def test_functions_with_bad_return_values(self):
268-
f = lambda cursor_offset, line: ('hi',)
272+
def f(cursor_offset, line):
273+
return ('hi',)
269274
with self.assertRaises(ValueError):
270275
self.edits.add('a', f)
271-
g = lambda cursor_offset, line: ('hi', 1, 2, 3)
276+
277+
def g(cursor_offset, line):
278+
return ('hi', 1, 2, 3)
272279
with self.assertRaises(ValueError):
273280
self.edits.add('b', g)
274281

275282
def test_config(self):
276-
f = lambda cursor_offset, line: ('hi', 2)
277-
g = lambda cursor_offset, line: ('hey', 3)
283+
def f(cursor_offset, line):
284+
return ('hi', 2)
285+
286+
def g(cursor_offset, line):
287+
return ('hey', 3)
278288
self.edits.add_config_attr('att', f)
279289
self.assertNotIn('att', self.edits)
280290

bpython/test/test_repl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ def test_paremeter_name_completion(self):
426426

427427
self.assertTrue(self.repl.complete())
428428
self.assertTrue(hasattr(self.repl.matches_iter, 'matches'))
429-
self.assertEqual(self.repl.matches_iter.matches, ['abc=', 'abd=', 'abs('])
429+
self.assertEqual(self.repl.matches_iter.matches,
430+
['abc=', 'abd=', 'abs('])
430431

431432

432433
class TestCliRepl(unittest.TestCase):

bpython/test/test_simpleeval.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ def test_matches_stdlib(self):
2121
def test_indexing(self):
2222
"""Literals can be indexed into"""
2323
self.assertEqual(simple_eval('[1,2][0]'), 1)
24-
self.assertEqual(simple_eval('a', {'a':1}), 1)
24+
self.assertEqual(simple_eval('a', {'a': 1}), 1)
2525

2626
def test_name_lookup(self):
2727
"""Names can be lookup up in a namespace"""
28-
self.assertEqual(simple_eval('a', {'a':1}), 1)
28+
self.assertEqual(simple_eval('a', {'a': 1}), 1)
2929
self.assertEqual(simple_eval('map'), map)
30-
self.assertEqual(simple_eval('a[b]', {'a':{'c':1}, 'b':'c'}), 1)
30+
self.assertEqual(simple_eval('a[b]', {'a': {'c': 1}, 'b': 'c'}), 1)
3131

3232
def test_allow_name_lookup(self):
3333
"""Names can be lookup up in a namespace"""
34-
self.assertEqual(simple_eval('a', {'a':1}), 1)
34+
self.assertEqual(simple_eval('a', {'a': 1}), 1)
3535

3636
def test_lookup_on_suspicious_types(self):
3737
class FakeDict(object):
@@ -72,7 +72,7 @@ def __add__(inner_self, other):
7272
def test_operators_on_numbers(self):
7373
self.assertEqual(simple_eval('-2'), -2)
7474
self.assertEqual(simple_eval('1 + 1'), 2)
75-
self.assertEqual(simple_eval('a - 2', {'a':1}), -1)
75+
self.assertEqual(simple_eval('a - 2', {'a': 1}), -1)
7676
with self.assertRaises(ValueError):
7777
simple_eval('2 * 3')
7878
with self.assertRaises(ValueError):
@@ -86,6 +86,7 @@ def test_nonexistant_names_raise(self):
8686
with self.assertRaises(EvaluationError):
8787
simple_eval('a')
8888

89+
8990
class TestEvaluateCurrentExpression(unittest.TestCase):
9091

9192
def assertEvaled(self, line, value, ns=None):
@@ -119,7 +120,7 @@ def test_nonsense(self):
119120
self.assertEvaled('"asdf"[1].a|bc', 's')
120121

121122
def test_with_namespace(self):
122-
self.assertEvaled('a[1].a|bc', 'd', {'a':'adsf'})
123+
self.assertEvaled('a[1].a|bc', 'd', {'a': 'adsf'})
123124
self.assertCannotEval('a[1].a|bc', {})
124125

125126
if __name__ == '__main__':

0 commit comments

Comments
 (0)