def test_serialize(self): store = yaml.YAMLFile() store.parse('key: value') out = BytesIO() store.serialize(out) assert out.getvalue() == b'key: value\n'
def test_parse_unicode_list(self): store = yaml.YAMLFile() store.parse(u'list:\n- zkouška') out = BytesIO() store.serialize(out) assert out.getvalue() == u'list:\n- zkouška\n'.encode('utf-8')
def test_ordering(self): store = yaml.YAMLFile() store.parse(''' foo: foo bar: bar baz: baz ''') assert store.units[0].source == 'foo' assert store.units[2].source == 'baz'
def test_edit_unicode(self): store = yaml.YAMLFile() store.parse('key: value') store.units[0].settarget(u'zkouška') out = BytesIO() store.serialize(out) assert out.getvalue() == u'key: zkouška\n'.encode('utf-8')
def test_edit(self): store = yaml.YAMLFile() store.parse('key: value') store.units[0].settarget('second') out = BytesIO() store.serialize(out) assert out.getvalue() == b'key: second\n'
def test_nested(self): store = yaml.YAMLFile() store.parse(''' foo: bar: bar baz: boo: booo ''') assert store.units[0].getid() == 'foo / bar' assert store.units[0].source == 'bar' assert store.units[1].getid() == 'foo / baz / boo' assert store.units[1].source == 'booo' out = BytesIO() store.serialize(out) assert out.getvalue() == b'''foo:
def test_invalid_value(self): store = yaml.YAMLFile() with pytest.raises(base.ParseError): store.parse('val: "\\u string"')
def test_invalid_key(self): store = yaml.YAMLFile() with pytest.raises(base.ParseError): store.parse('1: string')
def test_invalid_value(self): store = yaml.YAMLFile() assert pytest.raises(base.ParseError, store.parse, 'val: "\\u string"')
def test_invalid_key(self): store = yaml.YAMLFile() assert pytest.raises(base.ParseError, store.parse, 'yes: string')