Python 3: Fix YamlEnvironmentTest tests
In Python 3, this happens:
>>> 'foo' in ValueError('foo')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: argument of type 'ValueError' is not iterable
We have to cast the Exception to make the tests work.
Change-Id: Ifc06c9860412030dc697b264812a6bf78e10eb8b
This commit is contained in:
@@ -52,14 +52,14 @@ parameters: }
|
||||
def test_parse_string_environment(self):
|
||||
env = 'just string'
|
||||
expect = 'The environment is not a valid YAML mapping data type.'
|
||||
msg = self.assertRaises(ValueError, environment_format.parse, env)
|
||||
self.assertIn(expect, msg)
|
||||
e = self.assertRaises(ValueError, environment_format.parse, env)
|
||||
self.assertIn(expect, str(e))
|
||||
|
||||
def test_parse_document(self):
|
||||
env = '["foo" , "bar"]'
|
||||
expect = 'The environment is not a valid YAML mapping data type.'
|
||||
msg = self.assertRaises(ValueError, environment_format.parse, env)
|
||||
self.assertIn(expect, msg)
|
||||
e = self.assertRaises(ValueError, environment_format.parse, env)
|
||||
self.assertIn(expect, str(e))
|
||||
|
||||
|
||||
class YamlParseExceptions(testtools.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user