Skip to content

Commit 38c0a48

Browse files
committed
Improve OMTypedParser test coverage
Removing the extra lines + hitting convertString2 in tests has brought coverage up to 100%.
1 parent ca7ffaf commit 38c0a48

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

OMPython/OMTypedParser.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python
21
# -*- coding: utf-8 -*-
32
__author__ = "Anand Kalaiarasi Ganeson, ganan642@student.liu.se, 2012-03-19, and Martin Sjölund"
43
__license__ = """
@@ -52,8 +51,6 @@
5251
opAssoc,
5352
)
5453

55-
import sys
56-
5754

5855
def convertNumbers(s, l, toks):
5956
n = toks[0]
@@ -142,22 +139,3 @@ def parseString(string):
142139
if len(res) == 0:
143140
return
144141
return res[0]
145-
146-
147-
if __name__ == "__main__":
148-
testdata = """
149-
(1.0,{{1,true,3},{"4\\"
150-
",5.9,6,NONE ( )},record ABC
151-
startTime = ErrorLevel.warning,
152-
'stop*Time' = SOME(1.0)
153-
end ABC;})
154-
"""
155-
expected = (1.0, ((1, True, 3), ('4"\n', 5.9, 6, None), {"'stop*Time'": 1.0, 'startTime': 'ErrorLevel.warning'}))
156-
results = parseString(testdata)
157-
if results != expected:
158-
print("Results:", results)
159-
print("Expected:", expected)
160-
print("Failed")
161-
sys.exit(1)
162-
print("Matches expected output")
163-
print(type(results), repr(results))

tests/test_typedParser.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,17 @@ def test_str():
3737

3838
def test_UnStringable():
3939
pass
40+
41+
42+
def test_everything():
43+
# this test used to be in OMTypedParser.py's main()
44+
testdata = """
45+
(1.0,{{1,true,3},{"4\\"
46+
",5.9,6,NONE ( )},record ABC
47+
startTime = ErrorLevel.warning,
48+
'stop*Time' = SOME(1.0)
49+
end ABC;})
50+
"""
51+
expected = (1.0, ((1, True, 3), ('4"\n', 5.9, 6, None), {"'stop*Time'": 1.0, 'startTime': 'ErrorLevel.warning'}))
52+
results = typeCheck(testdata)
53+
assert results == expected

0 commit comments

Comments
 (0)