Beispiel #1
0
def test_override_missing_values():
    """Test the override_missing_values() function."""
    data = [[1, None], [2, 'Jill']]
    headers = [0, 'name']
    expected = ([[1, '<EMPTY>'], [2, 'Jill']], [0, 'name'])
    results = override_missing_value(data, headers, missing_value='<EMPTY>')

    assert expected == (list(results[0]), results[1])
Beispiel #2
0
def test_override_missing_values():
    """Test the override_missing_values() function."""
    data = [[1, None], [2, "Jill"]]
    headers = [0, "name"]
    expected = ([[1, "<EMPTY>"], [2, "Jill"]], [0, "name"])
    results = override_missing_value(data, headers, missing_value="<EMPTY>")

    assert expected == (list(results[0]), results[1])
Beispiel #3
0
def test_override_missing_value_with_style():
    """Test that *override_missing_value()* styles output."""
    class NullStyle(Style):
        styles = {Token.Output.Null: '#0f0'}

    headers = ['h1', 'h2']
    data = [[None, '2'], ['abc', None]]

    expected_headers = ['h1', 'h2']
    expected_data = [['\x1b[38;5;10m<null>\x1b[39m', '2'],
                     ['abc', '\x1b[38;5;10m<null>\x1b[39m']]
    results = override_missing_value(data,
                                     headers,
                                     style=NullStyle,
                                     missing_value="<null>")

    assert (expected_data, expected_headers) == (list(results[0]), results[1])
Beispiel #4
0
def test_override_missing_value_with_style():
    """Test that *override_missing_value()* styles output."""

    class NullStyle(Style):
        styles = {Token.Output.Null: "#0f0"}

    headers = ["h1", "h2"]
    data = [[None, "2"], ["abc", None]]

    expected_headers = ["h1", "h2"]
    expected_data = [
        ["\x1b[38;5;10m<null>\x1b[39m", "2"],
        ["abc", "\x1b[38;5;10m<null>\x1b[39m"],
    ]
    results = override_missing_value(
        data, headers, style=NullStyle, missing_value="<null>"
    )

    assert (expected_data, expected_headers) == (list(results[0]), results[1])