Ejemplo n.º 1
0
    def test_remove_control_chars_from(self):
        bad_messages = [({
            "processes": [
                1234,
                [[
                    u'☢cd≤Ω≈ç√∫˜µ≤\r\n', 0, 2.2, 12, 34,
                    'compiz\r\n', 1
                ]]
            ]
        }, {
            "processes": [
                1234,
                [[
                    u'☢cd≤Ω≈ç√∫˜µ≤', 0, 2.2, 12, 34, 'compiz',
                    1
                ]]
            ]
        })]
        good_messages = [{
            "processes":
            [1234, [[u'db🖫', 0, 2.2, 12, 34, u'☢compiz☢', 1]]]
        }]

        def is_converted_same(msg):
            new_msg = remove_control_chars_from(msg, None)
            if str(new_msg) == str(msg):
                return True
            return False

        for bad, good in bad_messages:
            self.assertFalse(is_converted_same(bad))
            self.assertTrue(remove_control_chars_from(bad, None) == good)

        for msg in good_messages:
            self.assertTrue(is_converted_same(msg))
Ejemplo n.º 2
0
    def test_remove_control_chars_from(self):
        bad_messages = [
            ({"processes":[1234,[[u'☢cd≤Ω≈ç√∫˜µ≤\r\n', 0, 2.2,12,34,'compiz\r\n',1]]]},
             {"processes":[1234,[[u'☢cd≤Ω≈ç√∫˜µ≤', 0, 2.2,12,34,'compiz',1]]]})
        ]
        good_messages = [
            {"processes":[1234,[[u'db🖫', 0, 2.2,12,34,u'☢compiz☢',1]]]}
        ]

        def is_converted_same(msg):
            new_msg = remove_control_chars_from(msg, None)
            if str(new_msg) == str(msg):
                return True
            return False

        for bad, good in bad_messages:
            self.assertFalse(is_converted_same(bad))
            self.assertTrue(remove_control_chars_from(bad, None) == good)

        for msg in good_messages:
            self.assertTrue(is_converted_same(msg))
Ejemplo n.º 3
0
 def is_converted_same(msg):
     new_msg = remove_control_chars_from(msg, None)
     if str(new_msg) == str(msg):
         return True
     return False
Ejemplo n.º 4
0
 def is_converted_same(msg):
     new_msg = remove_control_chars_from(msg, None)
     if str(new_msg) == str(msg):
         return True
     return False