示例#1
0
 def test3_string2hash(self):
     """ queue._string2hash() """
     assert queue._string2hash('a1\ta2\nb1\tb2') == {'a1': 'a2', 'b1': 'b2'}
     assert queue._string2hash('a1\x5c\ta2\nb1\tb2\\') == \
         {'a1\x5c': 'a2', 'b1': 'b2\\'}
     for value in ['a', ]:
         self.failUnlessRaises(queue.QueueError,
                               queue._string2hash,
                               (value))
示例#2
0
 def test3_string2hash(self):
     """ queue._string2hash() """
     assert queue._string2hash('a1\ta2\nb1\tb2') == {'a1': 'a2', 'b1': 'b2'}
     assert queue._string2hash('a1\x5c\ta2\nb1\tb2\\') == \
         {'a1\x5c': 'a2', 'b1': 'b2\\'}
     for value in [
             'a',
     ]:
         self.failUnlessRaises(queue.QueueError, queue._string2hash,
                               (value))
示例#3
0
 def test3_hash2string2hash(self):
     """ queue._hash2string()+queue._string2hash() """
     example = {"hi\\t\th\nere": "h\\ello\twor\nld"}
     converted = queue._hash2string(example)
     assert converted == "hi\\\\t\\th\\nere\th\\\\ello\\twor\\nld\n"
     back = queue._string2hash(converted)
     assert back == example
示例#4
0
 def test3_hash2string2hash(self):
     """ queue._hash2string()+queue._string2hash() """
     example = {"hi\\t\th\nere": "h\\ello\twor\nld"}
     converted = queue._hash2string(example)
     assert converted == "hi\\\\t\\th\\nere\th\\\\ello\\twor\\nld\n"
     back = queue._string2hash(converted)
     assert back == example