X Tutup
Skip to content

Commit 62fe244

Browse files
add skipped tests
add tests for examples of why the current naive approach isn't sufficient
1 parent fe49677 commit 62fe244

File tree

3 files changed

+73
-3
lines changed

3 files changed

+73
-3
lines changed

bpython/test/fodder/original.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,28 @@ def BlankLineInFunction(self):
2020
pass
2121
#EndTest
2222

23+
#StartTest-blank_line_in_try_catch
24+
try:
25+
1
26+
27+
except:
28+
2
29+
#EndTest
30+
31+
#StartTest-blank_line_in_try_catch_else
32+
try:
33+
1
34+
35+
except:
36+
2
37+
38+
else:
39+
3
40+
#EndTest
41+
42+
#StartTest-blank_trailing_line
43+
def foo():
44+
return 1
45+
46+
#EndTest
47+

bpython/test/fodder/processed.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,28 @@ def BlankLineInFunction(self):
1818

1919
pass
2020
#EndTest
21+
22+
#StartTest-blank_line_in_try_catch
23+
try:
24+
1
25+
26+
except:
27+
2
28+
#EndTest
29+
30+
#StartTest-blank_line_in_try_catch_else
31+
try:
32+
1
33+
34+
except:
35+
2
36+
37+
else:
38+
3
39+
#EndTest
40+
41+
#StartTest-blank_trailing_line
42+
def foo():
43+
return 1
44+
45+
#EndTest

bpython/test/test_preprocess.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
import re
66
import unittest
77

8+
try:
9+
import unittest2 as unittest
10+
except ImportError:
11+
import unittest
12+
skip = unittest.skip
13+
814
from bpython.curtsiesfrontend.interpreter import code_finished_will_parse
915
from bpython.curtsiesfrontend.preprocess import indent_empty_lines
1016

@@ -34,14 +40,17 @@ def assertCompiles(self, source):
3440

3541
def test_indent_empty_lines_nops(self):
3642
self.assertEqual(indent_empty('hello'), 'hello')
43+
self.assertEqual(indent_empty('hello\ngoodbye'), 'hello\ngoodbye')
44+
self.assertEqual(indent_empty('a\n b\nc\n'), 'a\n b\nc\n')
3745

3846
def assertShowWhitespaceEqual(self, a, b):
47+
print a
3948
self.assertEqual(
40-
indent_empty(a), b,
49+
a, b,
4150
''.join(difflib.context_diff(a.replace(' ', '~').splitlines(True),
4251
b.replace(' ', '~').splitlines(True),
43-
fromfile='original',
44-
tofile='processed',
52+
fromfile='actual',
53+
tofile='expected',
4554
n=5)))
4655

4756
def assertDefinitionIndented(self, obj):
@@ -71,3 +80,14 @@ def test_empty_line_within_class(self):
7180

7281
def test_blank_lines_in_for_loop(self):
7382
self.assertIndented('blank_lines_in_for_loop')
83+
84+
@skip("More advanced technique required: need to try compiling and backtracking")
85+
def test_blank_line_in_try_catch(self):
86+
self.assertIndented('blank_line_in_try_catch')
87+
88+
@skip("More advanced technique required: need to try compiling and backtracking")
89+
def test_blank_line_in_try_catch_else(self):
90+
self.assertIndented('blank_line_in_try_catch_else')
91+
92+
def test_blank_trailing_line(self):
93+
self.assertIndented('blank_trailing_line')

0 commit comments

Comments
 (0)
X Tutup