Skip to content

Commit 58ffc66

Browse files
committed
[test/parser] Update InvalidVersion tests
1 parent 837c322 commit 58ffc66

3 files changed

Lines changed: 6 additions & 15 deletions

File tree

test/test_parser_json.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import unittest
44

55
from odml.tools import dict_parser
6-
from odml.tools.parser_utils import ParserException
6+
from odml.tools.parser_utils import ParserException, InvalidVersionException
77

88

99
class TestJSONParser(unittest.TestCase):
@@ -40,12 +40,9 @@ def test_missing_version(self):
4040

4141
def test_invalid_version(self):
4242
filename = "invalid_version.json"
43-
message = "invalid odML document format version"
4443

4544
with open(os.path.join(self.basepath, filename)) as json_data:
4645
parsed_doc = json.load(json_data)
4746

48-
with self.assertRaises(ParserException) as exc:
47+
with self.assertRaises(InvalidVersionException):
4948
_ = self.json_reader.to_odml(parsed_doc)
50-
51-
self.assertIn(message, str(exc.exception))

test/test_parser_xml.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import unittest
33

44
from odml.tools import xmlparser
5-
from odml.tools.parser_utils import ParserException
5+
from odml.tools.parser_utils import ParserException, InvalidVersionException
66

77

88
class TestXMLParser(unittest.TestCase):
@@ -33,9 +33,6 @@ def test_missing_version(self):
3333

3434
def test_invalid_version(self):
3535
filename = "invalid_version.xml"
36-
message = "invalid odML document format version"
3736

38-
with self.assertRaises(ParserException) as exc:
37+
with self.assertRaises(InvalidVersionException):
3938
_ = self.xml_reader.from_file(os.path.join(self.basepath, filename))
40-
41-
self.assertIn(message, str(exc.exception))

test/test_parser_yaml.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import yaml
44

55
from odml.tools import dict_parser
6-
from odml.tools.parser_utils import ParserException
6+
from odml.tools.parser_utils import ParserException, InvalidVersionException
77

88

99
class TestYAMLParser(unittest.TestCase):
@@ -40,12 +40,9 @@ def test_missing_version(self):
4040

4141
def test_invalid_version(self):
4242
filename = "invalid_version.yaml"
43-
message = "invalid odML document format version"
4443

4544
with open(os.path.join(self.basepath, filename)) as raw_data:
4645
parsed_doc = yaml.load(raw_data)
4746

48-
with self.assertRaises(ParserException) as exc:
47+
with self.assertRaises(InvalidVersionException):
4948
_ = self.yaml_reader.to_odml(parsed_doc)
50-
51-
self.assertIn(message, str(exc.exception))

0 commit comments

Comments
 (0)