Exemplo n.º 1
0
    def test_to_file(self):
        """Write rio to file"""
        tmpf = TemporaryFile()
        s = Stanza(a_thing='something with "quotes like \\"this\\""',
                   number='42', name='fred')
        s.write(tmpf)
        tmpf.seek(0)
        self.assertEqual(tmpf.read(), b'''\
a_thing: something with "quotes like \\"this\\""
name: fred
number: 42
''')
Exemplo n.º 2
0
    def test_multiline_string(self):
        tmpf = TemporaryFile()
        s = Stanza(
            motto="war is peace\nfreedom is slavery\nignorance is strength")
        s.write(tmpf)
        tmpf.seek(0)
        self.assertEqual(tmpf.read(), b'''\
motto: war is peace
\tfreedom is slavery
\tignorance is strength
''')
        tmpf.seek(0)
        s2 = read_stanza(tmpf)
        self.assertEqual(s, s2)