示例#1
0
def convert_to_string(data, headers, **_):
    """Convert all *data* and *headers* to strings.

    Binary data that cannot be decoded is converted to a hexadecimal
    representation via :func:`binascii.hexlify`.

    :param iterable data: An :term:`iterable` (e.g. list) of rows.
    :param iterable headers: The column headers.
    :return: The processed data and headers.
    :rtype: tuple

    """
    return (([utils.to_string(v) for v in row]
             for row in data), [utils.to_string(h) for h in headers])
示例#2
0
def test_to_string_non_bytes():
    """Test that to_string() converts non-bytes to a string."""
    assert utils.to_string(1) == '1'
    assert utils.to_string(2.29) == '2.29'
示例#3
0
def test_to_string_bytes():
    """Test that to_string() converts bytes to a string."""
    assert utils.to_string(b"foo") == 'foo'