Skip to content

Commit e3dea1e

Browse files
committed
use exceptions in tests
1 parent 5bad20c commit e3dea1e

File tree

1 file changed

+38
-37
lines changed

1 file changed

+38
-37
lines changed

tests/test_parser.py

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import unittest
22
from snippet.snippet import extract_snippets
33
from snippet.config import Config
4+
from snippet import exceptions
45

56

67
newline = '\n'
@@ -49,42 +50,42 @@ def test_indent(self):
4950
sequence
5051
)
5152

52-
@unittest.expectedFailure
5353
def test_dedent_code(self):
54-
sequence = [f' {x}' for x in [start + 'test' + newline, A, B, stop]]
55-
sequence[-2] = sequence[-2].lstrip()
56-
self.go_exact(
57-
Config(),
58-
sequence
59-
)
54+
with self.assertRaises(exceptions.ValidationFailure):
55+
sequence = [f' {x}' for x in [start + 'test' + newline, A, B, stop]]
56+
sequence[-2] = sequence[-2].lstrip()
57+
self.go_exact(
58+
Config(),
59+
sequence
60+
)
6061

61-
@unittest.expectedFailure
6262
def test_unstarted(self):
63-
self.go_exact(
64-
Config(),
65-
[A, B, stop]
66-
)
63+
with self.assertRaises(exceptions.StartEndMismatch):
64+
self.go_exact(
65+
Config(),
66+
[A, B, stop]
67+
)
6768

68-
@unittest.expectedFailure
6969
def test_unfinished(self):
70-
self.go_exact(
71-
Config(),
72-
[start, 'test', newline, A, B]
73-
)
70+
with self.assertRaises(exceptions.StartEndMismatch):
71+
self.go_exact(
72+
Config(),
73+
[start, 'test', newline, A, B]
74+
)
7475

75-
@unittest.expectedFailure
7676
def test_double_start(self):
77-
self.go_exact(
78-
Config(),
79-
[start, 'test', newline, A, start, 'test again', newline, B, stop]
80-
)
77+
with self.assertRaises(exceptions.StartEndMismatch):
78+
self.go_exact(
79+
Config(),
80+
[start, 'test', newline, A, start, 'test again', newline, B, stop]
81+
)
8182

82-
@unittest.expectedFailure
8383
def test_double_stop(self):
84-
self.go_exact(
85-
Config(),
86-
[start, 'test', newline, A, stop, B, stop]
87-
)
84+
with self.assertRaises(exceptions.StartEndMismatch):
85+
self.go_exact(
86+
Config(),
87+
[start, 'test', newline, A, stop, B, stop]
88+
)
8889

8990
def test_prefix(self):
9091
self.go_exact(
@@ -104,19 +105,19 @@ def test_cloak(self):
104105
stop, 'other stuff']
105106
)
106107

107-
@unittest.expectedFailure
108108
def test_cloak_unstarted(self):
109-
self.go_exact(
110-
Config(),
111-
['some other stuff', start, 'test', newline, A, uncloak, B, stop, 'other stuff']
112-
)
109+
with self.assertRaises(exceptions.CloakMismatch):
110+
self.go_exact(
111+
Config(),
112+
['some other stuff', start, 'test', newline, A, uncloak, B, stop, 'other stuff']
113+
)
113114

114-
@unittest.expectedFailure
115115
def test_cloak_unfinished(self):
116-
self.go_exact(
117-
Config(),
118-
['some other stuff', start, 'test', newline, A, cloak, B, stop, 'other stuff']
119-
)
116+
with self.assertRaises(exceptions.CloakMismatch):
117+
self.go_exact(
118+
Config(),
119+
['some other stuff', start, 'test', newline, A, cloak, B, stop, 'other stuff']
120+
)
120121

121122
def test_multiple(self):
122123
sequence = [

0 commit comments

Comments
 (0)