Ejemplo 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.assertEqualDiff(tmpf.read(), r'''
a_thing: something with "quotes like \"this\""
name: fred
number: 42
'''[1:])
Ejemplo 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.assertEqualDiff(tmpf.read(), '''\
motto: war is peace
\tfreedom is slavery
\tignorance is strength
''')
        tmpf.seek(0)
        s2 = read_stanza(tmpf)
        self.assertEquals(s, s2)
Ejemplo n.º 3
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.assertEqualDiff(
            tmpf.read(), r'''
a_thing: something with "quotes like \"this\""
name: fred
number: 42
'''[1:])
Ejemplo n.º 4
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.assertEqualDiff(
            tmpf.read(), '''\
motto: war is peace
\tfreedom is slavery
\tignorance is strength
''')
        tmpf.seek(0)
        s2 = read_stanza(tmpf)
        self.assertEqual(s, s2)