Skip to content

Commit fe2234f

Browse files
committed
Failing gracefully if twisted isn't installed.
1 parent 55e196e commit fe2234f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

ometa/test/test_protocol.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
from twisted.trial import unittest
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
29

310
from ometa.grammar import OMeta
4-
from ometa.protocol import ParserProtocol
511
from ometa.runtime import ParseError
612

713

@@ -59,6 +65,8 @@ def abortConnection(self):
5965

6066

6167
class ParserProtocolTestCase(unittest.TestCase):
68+
skip = skip
69+
6270
def setUp(self):
6371
self.protocol = ParserProtocol(
6472
testGrammar, SenderFactory, StateFactory, {})

parsley.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import functools
22

33
from ometa.grammar import OMeta
4-
from ometa.protocol import ParserProtocol
54
from ometa.runtime import ParseError, EOFError, OMetaBase, expected
65
from terml.parser import parseTerm as term
76
from terml.nodes import termMaker
@@ -59,6 +58,7 @@ def makeProtocol(source, senderFactory, stateFactory, bindings=None,
5958
Create a Protocol implementation from a Parsley grammar.
6059
"""
6160

61+
from ometa.protocol import ParserProtocol
6262
if bindings is None:
6363
bindings = {}
6464
grammar = OMeta(source).parseGrammar(name)

0 commit comments

Comments
 (0)