Пример #1
0
    def test_float_value(self):
        data = format_line(
            OrderedDict([("key1", 342.23424), ("key2", -234234234.2342342)]))

        if sys.version_info < (3, 0):
            self.assertEqual(data, "key1=342.23424 key2=-234234234.234")
        else:
            self.assertEqual(data, "key1=342.23424 key2=-234234234.2342342")
Пример #2
0
    def test_string_value(self):
        data = format_line(
            OrderedDict([("key1",
                          """some random !@#$%^"&**_+-={}\\|;':,./<>?)"""),
                         ("key2", """here's a line with
more stuff on the next""")]))

        self.assertEqual(
            data,
            '''key1="some random !@#$%^\\"&**_+-={}\\|;\':,./<>?)" key2="here\'s a line with\nmore stuff on the next"'''
        )
Пример #3
0
def format(*args):
    for hash in args:
        output = format_line(hash)
        if output:
            yield output
Пример #4
0
 def test_empty_log_line(self):
     data = format_line({})
     self.assertEqual(data, "")
Пример #5
0
    def test_custom_float_format(self):
        data = format_line(
            OrderedDict([("key1", 342.23424),
                         ("key2", "%.7f" % -234234234.2342342)]))

        self.assertEqual(data, "key1=342.23424 key2=\"-234234234.2342342\"")
Пример #6
0
 def test_int_value(self):
     data = format_line(OrderedDict([("key1", -1), ("key2", 2342342)]))
     self.assertEqual(data, "key1=-1 key2=2342342")
Пример #7
0
 def test_boolean_values(self):
     data = format_line(OrderedDict([("key1", True), ("key2", False)]))
     self.assertEqual(data, "key1=true key2=false")
Пример #8
0
 def test_key_without_value(self):
     data = format_line(OrderedDict([("key1", None), ("key2", None)]))
     self.assertEqual(data, "key1= key2=")