summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn O'Loughlin <john.oloughlin@intel.com>2018-05-16 10:00:21 +0000
committerJohn O'Loughlin <john.oloughlin@intel.com>2018-08-02 09:49:04 +0000
commit00af29d52e4e13f7a58c0b6bddf4ef809e2f72e2 (patch)
tree7342485636afa5c8574281f112231a76a9bba321
parent74db27b3fc0447cceda2f60e3bf05420d5bad8b9 (diff)
Separate out test_parse_to_value_exception()
Separate out test_parse_to_value_exception(self) into 3 different methods:     test_parse_scanner(self)     test_parse_parser(self)     test_parse_reader(self) This ensures that each side effect is tested, even if one fails. JIRA: YARDSTICK-940 Change-Id: Ifdc84284c633fe1ddc1acf9cd985c5144030b430 Signed-off-by: John O Loughlin <john.oloughlin@intel.com>
-rw-r--r--yardstick/tests/unit/common/test_template_format.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/yardstick/tests/unit/common/test_template_format.py b/yardstick/tests/unit/common/test_template_format.py
index 56253efbc..6e4827e16 100644
--- a/yardstick/tests/unit/common/test_template_format.py
+++ b/yardstick/tests/unit/common/test_template_format.py
@@ -22,16 +22,21 @@ from yardstick.common import template_format
class TemplateFormatTestCase(unittest.TestCase):
- def test_parse_to_value_exception(self):
+ def test_parse_scanner(self):
- # TODO(elfoley): Don't hide the error that occurs in
- # template_format.parse
- # TODO(elfoley): Separate these tests; one per error type
with mock.patch.object(yaml, 'load') as yaml_loader:
yaml_loader.side_effect = yaml.scanner.ScannerError()
self.assertRaises(ValueError, template_format.parse, 'FOOBAR')
+
+ def test_parse_parser(self):
+
+ with mock.patch.object(yaml, 'load') as yaml_loader:
yaml_loader.side_effect = yaml.parser.ParserError()
self.assertRaises(ValueError, template_format.parse, 'FOOBAR')
+
+ def test_parse_reader(self):
+
+ with mock.patch.object(yaml, 'load') as yaml_loader:
yaml_loader.side_effect = \
yaml.reader.ReaderError('', '', '', '', '')
self.assertRaises(ValueError, template_format.parse, 'FOOBAR')