268
269
os.environ['DEBUG_PROC_CMDLINE'] = 'abcd 123'
269
270
self.assertEqual(os.environ['DEBUG_PROC_CMDLINE'], util.get_cmdline())
273
class TestLoadYaml(TestCase):
274
mydefault = "7b03a8ebace993d806255121073fed52"
276
def test_simple(self):
277
mydata = {'1': "one", '2': "two"}
278
self.assertEqual(util.load_yaml(yaml.dump(mydata)), mydata)
280
def test_nonallowed_returns_default(self):
281
# for now, anything not in the allowed list just returns the default.
282
myyaml = yaml.dump({'1': "one"})
283
self.assertEqual(util.load_yaml(blob=myyaml,
284
default=self.mydefault,
288
def test_bogus_returns_default(self):
290
self.assertEqual(util.load_yaml(blob=badyaml,
291
default=self.mydefault),
294
def test_unsafe_types(self):
295
# should not load complex types
296
unsafe_yaml = yaml.dump((1, 2, 3,))
297
self.assertEqual(util.load_yaml(blob=unsafe_yaml,
298
default=self.mydefault),
301
def test_python_unicode(self):
302
# complex type of python/unicde is explicitly allowed
303
myobj = {'1': unicode("FOOBAR")}
304
safe_yaml = yaml.dump(myobj)
305
self.assertEqual(util.load_yaml(blob=safe_yaml,
306
default=self.mydefault),
271
310
# vi: ts=4 expandtab