Skip to content

Commit 2a91000

Browse files
Remove usage of trial from most test cases.
1 parent 7cd0df5 commit 2a91000

File tree

5 files changed

+37
-14
lines changed

5 files changed

+37
-14
lines changed

ometa/test/helpers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import unittest
2+
3+
4+
class TestCase(unittest.TestCase):
5+
def assertRaises(self, ex, f, *args, **kwargs):
6+
try:
7+
f(*args, **kwargs)
8+
except ex as e:
9+
return e
10+
else:
11+
assert False, "%r didn't raise %r" % (f, ex)

ometa/test/test_pymeta.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
import operator
44
import sys
55
from textwrap import dedent
6-
from twisted.trial import unittest
6+
import unittest
7+
78
from ometa.grammar import OMeta, TermOMeta, TreeTransformerGrammar
89
from ometa.compat import OMeta1
910
from ometa.runtime import (ParseError, OMetaBase, OMetaGrammarBase, EOFError,
1011
expected, TreeTransformerBase)
1112
from ometa.interp import GrammarInterpreter, TrampolinedGrammarInterpreter
1213
from terml.parser import parseTerm as term
14+
from ometa.test.helpers import TestCase
1315

1416
try:
1517
basestring
@@ -53,7 +55,7 @@ def doIt(s):
5355

5456

5557

56-
class OMeta1TestCase(unittest.TestCase):
58+
class OMeta1TestCase(TestCase):
5759
"""
5860
Tests of OMeta grammar compilation, with v1 syntax.
5961
"""
@@ -418,7 +420,7 @@ def test_accidental_bareword(self):
418420

419421

420422

421-
class OMetaTestCase(unittest.TestCase):
423+
class OMetaTestCase(TestCase):
422424
"""
423425
Tests of OMeta grammar compilation.
424426
"""
@@ -1076,7 +1078,7 @@ def test_args(self):
10761078

10771079

10781080

1079-
class PyExtractorTest(unittest.TestCase):
1081+
class PyExtractorTest(TestCase):
10801082
"""
10811083
Tests for finding Python expressions in OMeta grammars.
10821084
"""
@@ -1111,7 +1113,7 @@ def test_expressions(self):
11111113
self.assertRaises(ParseError, o.pythonExpr)
11121114

11131115

1114-
class MakeGrammarTest(unittest.TestCase):
1116+
class MakeGrammarTest(TestCase):
11151117
"""
11161118
Test the definition of grammars via the 'makeGrammar' method.
11171119
"""
@@ -1325,7 +1327,7 @@ def interp(result, error):
13251327

13261328

13271329

1328-
class TreeTransformerTestCase(unittest.TestCase):
1330+
class TreeTransformerTestCase(TestCase):
13291331

13301332
def compile(self, grammar, namespace=None):
13311333
"""
@@ -1439,7 +1441,7 @@ def test_foreign(self):
14391441

14401442

14411443

1442-
class ErrorReportingTests(unittest.TestCase):
1444+
class ErrorReportingTests(TestCase):
14431445

14441446

14451447
def compile(self, grammar):

ometa/test/test_runtime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from twisted.trial import unittest
21
from ometa.runtime import OMetaBase, ParseError, expected, eof
2+
from ometa.test.helpers import TestCase
33

4-
class RuntimeTests(unittest.TestCase):
4+
class RuntimeTests(TestCase):
55
"""
66
Tests for L{pymeta.runtime}.
77
"""

ometa/test/test_tube.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import absolute_import
22

3-
from twisted.trial import unittest
3+
import unittest
44
from twisted.python.compat import iterbytes
55

66

@@ -22,7 +22,7 @@ def receive(self, data):
2222
self.received.append(data)
2323

2424

25-
class TrampolinedParserTestCase(unittest.SynchronousTestCase):
25+
class TrampolinedParserTestCase(unittest.TestCase):
2626
"""
2727
Tests for L{ometa.tube.TrampolinedParser}
2828
"""

terml/test/test_terml.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
from twisted.trial import unittest
1+
import unittest
22
from ometa.runtime import ParseError
33
from terml.nodes import Tag, Term, coerceToTerm, TermMaker, termMaker
44
from terml.parser import TermLParser, character, parseTerm
55

66

7-
class TermMakerTests(unittest.TestCase):
7+
class TestCase(unittest.TestCase):
8+
def assertRaises(self, ex, f, *args, **kwargs):
9+
try:
10+
f(*args, **kwargs)
11+
except ex as e:
12+
return e
13+
else:
14+
assert False, "%r didn't raise %r" % (f, ex)
15+
16+
17+
class TermMakerTests(TestCase):
818
def test_make(self):
919
m = TermMaker()
1020
t1 = m.Foo(1, 'a', m.Baz())
1121
self.assertEqual(t1, parseTerm('Foo(1, "a", Baz)'))
1222

1323

14-
class ParserTest(unittest.TestCase):
24+
class ParserTest(TestCase):
1525
"""
1626
Test TermL parser rules.
1727
"""

0 commit comments

Comments
 (0)