Skip to content

Commit 8609025

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

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

OMPython/OMTypedParser.py

Lines changed: 0 additions & 20 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__ = """
@@ -142,22 +141,3 @@ def parseString(string):
142141
if len(res) == 0:
143142
return
144143
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)