How to use the pysoa.common.logging.SyslogHandler._cleanly_slice_encoded_string function in pysoa

To help you get started, we’ve selected a few pysoa examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eventbrite / pysoa / tests / unit / common / test_logging.py View on Github external
assert SyslogHandler._cleanly_slice_encoded_string(
            b'Hello world, this has no multi-byte characters',
            18
        ) == (
            b'Hello world, this ',
            b'has no multi-byte characters',
        )

        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            12
        ) == (
            b'This string ',
            b'\xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            13
        ) == (
            b'This string ',
            b'\xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            14
        ) == (
            b'This string ',
            b'\xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            15
github eventbrite / pysoa / tests / unit / common / test_logging.py View on Github external
assert SyslogHandler._cleanly_slice_encoded_string(
            b'Hello world, this has no multi-byte characters',
            15
        ) == (
            b'Hello world, th',
            b'is has no multi-byte characters',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'Hello world, this has no multi-byte characters',
            16
        ) == (
            b'Hello world, thi',
            b's has no multi-byte characters',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'Hello world, this has no multi-byte characters',
            17
        ) == (
            b'Hello world, this',
            b' has no multi-byte characters',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'Hello world, this has no multi-byte characters',
            18
        ) == (
            b'Hello world, this ',
            b'has no multi-byte characters',
        )

        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
github eventbrite / pysoa / tests / unit / common / test_logging.py View on Github external
)
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            42
        ) == (
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d',
            b'\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            43
        ) == (
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d',
            b'\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            44
        ) == (
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb',
            b' characters!',
        )

        # There's not really anything we can do about making this detect modifiers and not split between the base
        # character and modifying character. So all we really care about is that the resulting strings successfully
        # decode without errors.
        b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d'.decode('utf-8')
        b'\xf0\x9f\x8f\xbb characters!'.decode('utf-8')
github eventbrite / pysoa / tests / unit / common / test_logging.py View on Github external
)
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            37
        ) == (
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte ',
            b'\xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            38
        ) == (
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte ',
            b'\xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            39
        ) == (
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte ',
            b'\xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            40
        ) == (
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d',
            b'\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            41
github eventbrite / pysoa / tests / unit / common / test_logging.py View on Github external
assert SyslogHandler._cleanly_slice_encoded_string(
            b'Hello world, this has no multi-byte characters',
            17
        ) == (
            b'Hello world, this',
            b' has no multi-byte characters',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'Hello world, this has no multi-byte characters',
            18
        ) == (
            b'Hello world, this ',
            b'has no multi-byte characters',
        )

        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            12
        ) == (
            b'This string ',
            b'\xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            13
        ) == (
            b'This string ',
            b'\xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            14
github eventbrite / pysoa / tests / unit / common / test_logging.py View on Github external
)
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            19
        ) == (
            b'This string \xf0\x9f\xa4\xae ha',
            b's \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            21
        ) == (
            b'This string \xf0\x9f\xa4\xae has ',
            b'\xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            22
        ) == (
            b'This string \xf0\x9f\xa4\xae has ',
            b'\xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            23
        ) == (
            b'This string \xf0\x9f\xa4\xae has ',
            b'\xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            24
github eventbrite / pysoa / tests / unit / common / test_logging.py View on Github external
)
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            38
        ) == (
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte ',
            b'\xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            39
        ) == (
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte ',
            b'\xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            40
        ) == (
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d',
            b'\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            41
        ) == (
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d',
            b'\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            42
github eventbrite / pysoa / tests / unit / common / test_logging.py View on Github external
)
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'Hello world, this has no multi-byte characters',
            16
        ) == (
            b'Hello world, thi',
            b's has no multi-byte characters',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'Hello world, this has no multi-byte characters',
            17
        ) == (
            b'Hello world, this',
            b' has no multi-byte characters',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'Hello world, this has no multi-byte characters',
            18
        ) == (
            b'Hello world, this ',
            b'has no multi-byte characters',
        )

        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            12
        ) == (
            b'This string ',
            b'\xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
github eventbrite / pysoa / tests / unit / common / test_logging.py View on Github external
)
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            13
        ) == (
            b'This string ',
            b'\xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            14
        ) == (
            b'This string ',
            b'\xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            15
        ) == (
            b'This string ',
            b'\xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            16
        ) == (
            b'This string \xf0\x9f\xa4\xae',
            b' has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'This string \xf0\x9f\xa4\xae has \xf0\x9f\x9b\x8c multi-byte \xe2\x9c\x8d\xf0\x9f\x8f\xbb characters!',
            19
github eventbrite / pysoa / tests / unit / common / test_logging.py View on Github external
def test_cleanly_slice_encoded_string(self):
        # b'\xf0\x9f\xa4\xae' = barf face
        # b'\xf0\x9f\x98\xbb' = cat with heart eyes
        # b'\xf0\x9f\x9b\x8c' = bed
        # b'\xf0\x9f\x92\xb8' = money with wings
        # b'\xe2\x9c\x8d\xf0\x9f\x8f\xbb' = hand writing with pen, lightest skin
        # b'\xe2\x9c\x8d\xf0\x9f\x8f\xbf' = hand writing with pen, darkest skin

        assert SyslogHandler._cleanly_slice_encoded_string(
            b'Hello world, this has no multi-byte characters',
            15
        ) == (
            b'Hello world, th',
            b'is has no multi-byte characters',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'Hello world, this has no multi-byte characters',
            16
        ) == (
            b'Hello world, thi',
            b's has no multi-byte characters',
        )
        assert SyslogHandler._cleanly_slice_encoded_string(
            b'Hello world, this has no multi-byte characters',
            17