X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Ftests%2Funit%2Fcommon%2Ftest_template_format.py;h=6e4827e167ccf69a6d284b21e9aa9df87e933e7c;hb=fd5fdb646ae46819fe2f80e35d0d2630a620e8ee;hp=44aa80333fa7557038dcb21049379b99f58b2af1;hpb=ccc7cf93bd769f2b9255ac59e93751535b463f2a;p=yardstick.git diff --git a/yardstick/tests/unit/common/test_template_format.py b/yardstick/tests/unit/common/test_template_format.py index 44aa80333..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') @@ -45,10 +50,3 @@ class TemplateFormatTestCase(unittest.TestCase): "Resources: {}\n" \ "Outputs: {}" self.assertRaises(ValueError, template_format.parse, yaml2) - - -def main(): - unittest.main() - -if __name__ == '__main__': - main()