How to use the pytablewriter.EmptyTableNameError function in pytablewriter

To help you get started, we’ve selected a few pytablewriter 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 thombashi / pytablewriter / test / writer / text / test_javascript_writer.py View on Github external
["v1 v1", "v2 v2", "v3 v3"]
            ];
            """
        ),
    ),
]

exception_test_data_list = [
    Data(
        table="",
        indent=normal_test_data_list[0].indent,
        header=normal_test_data_list[0].header,
        value=normal_test_data_list[0].value,
        is_write_header=True,
        is_dti_fmt=True,
        expected=pytablewriter.EmptyTableNameError,
    )
] + [
    Data(
        table="dummy",
        indent=0,
        header=header,
        value=value,
        is_write_header=True,
        is_dti_fmt=True,
        expected=pytablewriter.EmptyTableDataError,
    )
    for header, value in itertools.product([None, [], ""], [None, [], ""])
]

table_writer_class = pytablewriter.JavaScriptTableWriter
github thombashi / pytablewriter / test / writer / text / test_numpy_writer.py View on Github external
                    expected=ptw.EmptyTableNameError,
                )
            ]
        ],
    )
    def test_exception(self, table, indent, header, value, expected):
        writer = table_writer_class()
        writer.table_name = table
        writer.set_indent_level(indent)
        writer.headers = header
        writer.value_matrix = value

        with pytest.raises(expected):
            writer.write_table()
github thombashi / pytablewriter / test / test_elasticsearch_writer.py View on Github external
import pytablewriter as ptw
import pytest
import simplejson as json
import six  # noqa: W0611

from ._common import print_test_result
from .data import headers, value_matrix


inf = Decimal("Infinity")
nan = None

Data = collections.namedtuple("Data", "table header value expected")

exception_test_data_list = [
    Data(table="", header=headers, value=value_matrix, expected=ptw.EmptyTableNameError),
    Data(table="dummy", header=[], value=[], expected=ptw.EmptyTableDataError),
    Data(table="dummy", header=headers, value=[], expected=ptw.EmptyValueError),
]

table_writer_class = ptw.ElasticsearchWriter


class Test_ElasticsearchWriter__get_mappings(object):
    @pytest.mark.skipif("platform.system() == 'Windows' and six.PY2")
    def test_normal(self):
        writer = table_writer_class()
        writer.table_name = "es mappings"
        writer.headers = [
            "text",
            "byte",
            "short",
github thombashi / pytablewriter / test / writer / text / test_toml_writer.py View on Github external
c = 0.01
[[float]]
a = 1.2
b = 999999.123
c = 0.001

""",
    ),
]

exception_test_data_list = [
    Data(table_name="dummy", header=header, value=value, expected=ptw.EmptyTableDataError)
    for header, value in itertools.product([None, [], ""], [None, [], ""])
] + [
    Data(table_name="empty_header", header=None, value=value_matrix, expected=ptw.EmptyHeaderError),
    Data(table_name=None, header=headers, value=value_matrix, expected=ptw.EmptyTableNameError),
]

table_writer_class = ptw.TomlTableWriter


class Test_TomlTableWriter_write_new_line(object):
    def test_normal(self, capsys):
        writer = table_writer_class()
        writer.write_null_line()

        out, _err = capsys.readouterr()
        assert out == "\n"


class Test_TomlTableWriter_write_table(object):
    @pytest.mark.xfail(run=False)
github thombashi / pytablewriter / test / writer / binary / test_sqlite_writer.py View on Github external
),
    ),
    Data(
        table="empty header",
        header=[],
        value=value_matrix,
        expected=TableData(
            "empty_header",
            ["A", "B", "C", "D", "E"],
            [[1, 123.1, "a", 1, 1], [2, 2.2, "bb", 2.2, 2.2], [3, 3.3, "ccc", 3, "cccc"]],
        ),
    ),
]

exception_test_data_list = [
    Data(table="", header=headers, value=value_matrix, expected=ptw.EmptyTableNameError),
    Data(table="dummy", header=[], value=[], expected=ptw.EmptyTableDataError),
    Data(table="dummy", header=headers, value=[], expected=ptw.EmptyValueError),
]


@pytest.mark.xfail(run=False)
class Test_SqliteTableWriter_write_table(object):
    @pytest.mark.parametrize(
        ["table", "header", "value", "expected"],
        [[data.table, data.header, data.value, data.expected] for data in normal_test_data_list],
    )
    def test_normal(self, tmpdir, table, header, value, expected):
        test_file_path = tmpdir.join("test.sqlite")

        writer = ptw.SqliteTableWriter()
        writer.open(str(test_file_path))
github thombashi / pytablewriter / test / writer / text / test_pandas_writer.py View on Github external
]

exception_test_data_list = [
    Data(
        table="dummy",
        indent=normal_test_data_list[0].indent,
        header=[],
        value=[],
        expected=pytablewriter.EmptyTableDataError,
    ),
    Data(
        table="",
        indent=normal_test_data_list[0].indent,
        header=normal_test_data_list[0].header,
        value=normal_test_data_list[0].value,
        expected=pytablewriter.EmptyTableNameError,
    ),
]

table_writer_class = pytablewriter.PandasDataFrameWriter


class Test_PandasDataFrameWriter_write_new_line(object):
    def test_normal(self, capsys):
        writer = table_writer_class()
        writer.write_null_line()

        out, _err = capsys.readouterr()
        assert out == "\n"


class Test_PandasDataFrameWriter_write_table(object):
github thombashi / pytablewriter / test / writer / text / test_python_code_writer.py View on Github external
                    expected=ptw.EmptyTableNameError,
                )
            ]
        ],
    )
    def test_exception(self, table, indent, header, value, expected):
        writer = table_writer_class()
        writer.table_name = table
        writer.set_indent_level(indent)
        writer.headers = header
        writer.value_matrix = value

        with pytest.raises(expected):
            writer.write_table()