Ejemplo n.º 1
0
    def test_blank_line(self):
        s = Stanza(none='', one='\n', two='\n\n')
        self.assertEqualDiff(s.to_string(), """\
none:\x20
one:\x20
\t
two:\x20
\t
\t
""")
        s2 = read_stanza(s.to_lines())
        self.assertEquals(s, s2)
Ejemplo n.º 2
0
    def test_whitespace_value(self):
        s = Stanza(space=' ', tabs='\t\t\t', combo='\n\t\t\n')
        self.assertEqualDiff(s.to_string(), """\
combo:\x20
\t\t\t
\t
space:\x20\x20
tabs: \t\t\t
""")
        s2 = read_stanza(s.to_lines())
        self.assertEquals(s, s2)
        self.rio_file_stanzas([s])
Ejemplo n.º 3
0
    def test_blank_line(self):
        s = Stanza(none='', one='\n', two='\n\n')
        self.assertEqualDiff(s.to_string(), """\
none:\x20
one:\x20
\t
two:\x20
\t
\t
""")
        s2 = read_stanza(s.to_lines())
        self.assertEqual(s, s2)
Ejemplo n.º 4
0
    def test_whitespace_value(self):
        s = Stanza(space=' ', tabs='\t\t\t', combo='\n\t\t\n')
        self.assertEqualDiff(s.to_string(), """\
combo: 
\t\t\t
\t
space:  
tabs: \t\t\t
""")
        s2 = read_stanza(s.to_lines())
        self.assertEquals(s, s2)
        self.rio_file_stanzas([s])
Ejemplo n.º 5
0
 def _prepare_info(self):
     """Write information about a pending lock to a temporary file.
     """
     import socket
     # XXX: is creating this here inefficient?
     config = bzrlib.config.GlobalConfig()
     try:
         user = config.user_email()
     except errors.NoEmailInUsername:
         user = config.username()
     s = Stanza(hostname=socket.gethostname(),
                pid=str(os.getpid()),
                start_time=str(int(time.time())),
                nonce=self.nonce,
                user=user,
                )
     return s.to_string()
Ejemplo n.º 6
0
 def _prepare_info(self):
     """Write information about a pending lock to a temporary file.
     """
     import socket
     # XXX: is creating this here inefficient?
     config = bzrlib.config.GlobalConfig()
     try:
         user = config.user_email()
     except errors.NoEmailInUsername:
         user = config.username()
     s = Stanza(
         hostname=socket.gethostname(),
         pid=str(os.getpid()),
         start_time=str(int(time.time())),
         nonce=self.nonce,
         user=user,
     )
     return s.to_string()
Ejemplo n.º 7
0
 def test_empty_value(self):
     """Serialize stanza with empty field"""
     s = Stanza(empty='')
     self.assertEqualDiff(s.to_string(),
             "empty: \n")
Ejemplo n.º 8
0
 def test_backslash(self):
     s = Stanza(q='\\')
     t = s.to_string()
     self.assertEqualDiff(t, 'q: \\\n')
     s2 = read_stanza(s.to_lines())
     self.assertEquals(s, s2)
Ejemplo n.º 9
0
 def test_empty_value(self):
     """Serialize stanza with empty field"""
     s = Stanza(empty='')
     self.assertEqualDiff(s.to_string(), "empty: \n")
Ejemplo n.º 10
0
 def test_backslash(self):
     s = Stanza(q='\\')
     t = s.to_string()
     self.assertEqualDiff(t, 'q: \\\n')
     s2 = read_stanza(s.to_lines())
     self.assertEqual(s, s2)