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)
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])
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)
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])
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()
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()
def test_empty_value(self): """Serialize stanza with empty field""" s = Stanza(empty='') self.assertEqualDiff(s.to_string(), "empty: \n")
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)
def test_empty_value(self): """Serialize stanza with empty field""" s = Stanza(empty='') self.assertEqualDiff(s.to_string(), "empty: \n")
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)