# Path: test/_common.py
# def print_test_result(expected, actual, error=None):
#     print(f"[expected]\n{expected}\n")
#     print(f"[actual]\n{actual}\n")
# 
#     if error:
#         print(error, file=sys.stderr)
# 
#     print("----------------------------------------")
# 
# Path: test/data.py
# TIME = datetime.datetime(2017, 1, 1, 0, 0, 0)
# INF = float("inf")
# NAN = float("nan")


import collections
import itertools
import pytest
import pytablewriter as ptw
from textwrap import dedent
from ..._common import print_test_result
from ...data import (
    float_header_list,
    float_value_matrix,
    headers,
    mix_header_list,
    mix_value_matrix,
    value_matrix,
    value_matrix_iter,
    value_matrix_with_none,
)
            for data in normal_test_data_list
        ],
    )
    def test_normal(self, capsys, col_delim, header, value, expected):
        writer = table_writer_class(column_delimiter=col_delim, headers=header, value_matrix=value)
        writer.write_table()

        out, err = capsys.readouterr()
        print_test_result(expected=expected, actual=out, error=err)
        assert out == expected
        assert writer.dumps() == expected
        assert str(writer) == expected

        # margin setting must be ignored
        writer.margin = 1
        out = writer.dumps()
        print_test_result(expected=expected, actual=out)
        assert out == expected

    def test_normal_escape_formula_injection(self, capsys):
        writer = table_writer_class(
            headers=["a", "b", "c", "d", "e"],
            value_matrix=[["a+b", "=a+b", "-a+b", "+a+b", "@a+b"]],
        )
        writer.update_preprocessor(is_escape_formula_injection=True)
        writer.write_table()
        expected = r""""a","b","c","d","e"
"a+b","\"=a+b","\"-a+b","\"+a+b","\"@a+b"
"""
        out, err = capsys.readouterr()

# Path: test/_common.py
# def print_test_result(expected, actual, error=None):
#     print(f"[expected]\n{expected}\n")
#     print(f"[actual]\n{actual}\n")
# 
#     if error:
#         print(error, file=sys.stderr)
# 
#     print("----------------------------------------")
# 
# Path: test/data.py
# TIME = datetime.datetime(2017, 1, 1, 0, 0, 0)
# INF = float("inf")
# NAN = float("nan")


# Path: test/writer/text/test_csv_writer.py
import collections
import itertools
import pytest
import pytablewriter as ptw
from textwrap import dedent
from ..._common import print_test_result
from ...data import (
    float_header_list,
    float_value_matrix,
    headers,
    mix_header_list,
    mix_value_matrix,
    value_matrix,
    value_matrix_iter,
    value_matrix_with_none,
)

            for data in normal_test_data_list
        ],
    )
    def test_normal(self, capsys, col_delim, header, value, expected):
        writer = table_writer_class(column_delimiter=col_delim, headers=header, value_matrix=value)
        writer.write_table()

        out, err = capsys.readouterr()
        print_test_result(expected=expected, actual=out, error=err)
        assert out == expected
        assert writer.dumps() == expected
        assert str(writer) == expected

        # margin setting must be ignored
        writer.margin = 1
        out = writer.dumps()
        print_test_result(expected=expected, actual=out)
        assert out == expected

    def test_normal_escape_formula_injection(self, capsys):
        writer = table_writer_class(
            headers=["a", "b", "c", "d", "e"],
            value_matrix=[["a+b", "=a+b", "-a+b", "+a+b", "@a+b"]],
        )
        writer.update_preprocessor(is_escape_formula_injection=True)
        writer.write_table()
        expected = r""""a","b","c","d","e"
"a+b","\"=a+b","\"-a+b","\"+a+b","\"@a+b"
"""
        out, err = capsys.readouterr()

        print_test_result(expected=expected, actual=out, error=err)