1
- try :
2
- from twisted .trial import unittest
3
- from ometa .protocol import ParserProtocol
4
- except ImportError :
5
- import unittest
6
- skip = "twisted not installed or usable"
7
- else :
8
- skip = None
1
+ import unittest
2
+
3
+ import pytest
9
4
10
5
from ometa .grammar import OMeta
11
6
from ometa .runtime import ParseError
12
7
13
8
9
+ protocol = pytest .importorskip ('ometa.protocol' )
10
+ ParserProtocol = protocol .ParserProtocol
11
+
14
12
testingGrammarSource = """
15
13
16
14
someA = ('a' 'a') -> receiver('a')
@@ -69,11 +67,7 @@ def abortConnection(self):
69
67
70
68
71
69
class ParserProtocolTestCase (unittest .TestCase ):
72
- skip = skip
73
-
74
70
def setUp (self ):
75
- if skip is not None :
76
- raise unittest .SkipTest (skip )
77
71
self .protocol = ParserProtocol (
78
72
testGrammar , SenderFactory , ReceiverFactory , {})
79
73
@@ -168,8 +162,8 @@ def test_parseFailure(self):
168
162
self .protocol .makeConnection (transport )
169
163
self .protocol .dataReceived ('b' )
170
164
self .failIfEqual (self .protocol .receiver .lossReason , None )
171
- self .failUnlessIsInstance ( self . protocol . receiver . lossReason . value ,
172
- ParseError )
165
+ self .assertTrue (
166
+ isinstance ( self . protocol . receiver . lossReason . value , ParseError ) )
173
167
self .assert_ (transport .aborted )
174
168
175
169
def test_exceptionsRaisedFromReceiver (self ):
@@ -181,8 +175,8 @@ def test_exceptionsRaisedFromReceiver(self):
181
175
self .protocol .makeConnection (transport )
182
176
self .protocol .dataReceived ('e' )
183
177
self .failIfEqual (self .protocol .receiver .lossReason , None )
184
- self .failUnlessIsInstance ( self . protocol . receiver . lossReason . value ,
185
- SomeException )
178
+ self .assertTrue (
179
+ isinstance ( self . protocol . receiver . lossReason . value , SomeException ) )
186
180
self .assert_ (transport .aborted )
187
181
188
182
def test_dataIgnoredAfterDisconnection (self ):
0 commit comments