mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-12-12 06:07:56 +00:00
Fix yaml parsing of "null"
This commit is contained in:
parent
ca8eda839d
commit
288dc12796
@ -10,3 +10,8 @@ class UtilsTests(unittest.TestCase):
|
|||||||
self.assertEqual("sub1.domain.com", utils.common_domain("sub1.domain.com", "sub2.sub1.domain.com"))
|
self.assertEqual("sub1.domain.com", utils.common_domain("sub1.domain.com", "sub2.sub1.domain.com"))
|
||||||
self.assertEqual("com", utils.common_domain("domain1.com", "domain2.com"))
|
self.assertEqual("com", utils.common_domain("domain1.com", "domain2.com"))
|
||||||
self.assertEqual("domain.com", utils.common_domain("sub.domain.com", "ub.domain.com"))
|
self.assertEqual("domain.com", utils.common_domain("sub.domain.com", "ub.domain.com"))
|
||||||
|
|
||||||
|
def test_parse_yaml_value(self):
|
||||||
|
self.assertEqual(True, utils.parse_yaml_value("true"))
|
||||||
|
self.assertEqual(False, utils.parse_yaml_value("false"))
|
||||||
|
self.assertEqual(None, utils.parse_yaml_value("null"))
|
||||||
|
@ -13,10 +13,13 @@ def random_string(length):
|
|||||||
|
|
||||||
def parse_yaml_value(v):
|
def parse_yaml_value(v):
|
||||||
"""
|
"""
|
||||||
Parse a yaml-formatted string
|
Parse a yaml-formatted string. This is fairly basic and should only be used
|
||||||
|
for parsing of elementary values.
|
||||||
"""
|
"""
|
||||||
if v.isdigit():
|
if v.isdigit():
|
||||||
v = int(v)
|
v = int(v)
|
||||||
|
elif v == "null":
|
||||||
|
v = None
|
||||||
elif v in ["true", "false"]:
|
elif v in ["true", "false"]:
|
||||||
v = (v == "true")
|
v = (v == "true")
|
||||||
return v
|
return v
|
||||||
|
Loading…
Reference in New Issue
Block a user