# Path: pytablereader/interface.py
# class AbstractTableReader(TableLoaderInterface, metaclass=abc.ABCMeta):
#     """
#     The abstract class of table data file loader.
# 
#     .. py:attribute:: table_name
# 
#         Table name string.
# 
#     .. py:attribute:: source
# 
#         Table data source to load.
#     """
# 
#     __table_count_lock = threading.Lock()
#     __global_table_count = 0
#     __format_table_count = {}
# 
#     @property
#     def source_type(self):
#         return self._validator.source_type
# 
#     @property
#     def quoting_flags(self):
#         return self.__quoting_flags
# 
#     @property
#     def dp_extractor(self):
#         return self.__dp_extractor
# 
#     def __init__(self, source, quoting_flags, type_hints, type_hint_rules=None):
#         self.table_name = tnt.DEFAULT
#         self.source = source
#         self.__quoting_flags = quoting_flags
#         self.type_hints = type_hints
#         self.type_hint_rules = type_hint_rules
#         self._validator = None
#         self._logger = None
# 
#         self.__dp_extractor = DataPropertyExtractor()
#         self.__dp_extractor.quoting_flags = self.quoting_flags
#         self.__dp_extractor.update_strict_level_map({typepy.Typecode.BOOL: 1})
# 
#     def get_format_key(self):
#         return f"{self.format_name:s}{self.__get_format_table_count():d}"
# 
#     def make_table_name(self):
#         return self._make_table_name()
# 
#     def inc_table_count(self):
#         with self.__table_count_lock:
#             self.__global_table_count += 1
#             self.__format_table_count[self.format_name] = self.__get_format_table_count() + 1
# 
#     @abc.abstractmethod
#     def _get_default_table_name_template(self):  # pragma: no cover
#         pass
# 
#     def _validate(self):
#         self._validate_table_name()
#         self._validate_source()
# 
#     def _validate_table_name(self):
#         try:
#             if typepy.is_null_string(self.table_name):
#                 raise ValueError("table name is empty")
#         except (TypeError, AttributeError):
#             raise TypeError("table_name must be a string")
# 
#     def _validate_source(self):
#         self._validator.validate()
# 
#     def __get_format_table_count(self):
#         return self.__format_table_count.get(self.format_name, 0)
# 
#     def _get_filename_tablename_mapping(self):
#         filename = ""
#         if all([self.source_type == SourceType.FILE, typepy.is_not_null_string(self.source)]):
#             filename = path.Path(self.source).stem
# 
#         return (tnt.FILENAME, filename)
# 
#     def _get_basic_tablename_keyvalue_mapping(self):
#         from collections import OrderedDict
# 
#         return OrderedDict(
#             [
#                 (tnt.DEFAULT, self._get_default_table_name_template()),
#                 (tnt.FORMAT_NAME, self.format_name),
#                 (tnt.FORMAT_ID, str(self.__get_format_table_count())),
#                 (tnt.GLOBAL_ID, str(self.__global_table_count)),
#                 self._get_filename_tablename_mapping(),
#             ]
#         )
# 
#     def _expand_table_name_format(self, table_name_kv_mapping):
#         self._validate_table_name()
# 
#         table_name = self.table_name
#         for template, value in table_name_kv_mapping.items():
#             table_name = table_name.replace(template, value)
# 
#         return self._sanitize_table_name(table_name)
# 
#     def _make_table_name(self):
#         self._validate_table_name()
# 
#         return self._expand_table_name_format(self._get_basic_tablename_keyvalue_mapping())
# 
#     @staticmethod
#     def _sanitize_table_name(table_name):
#         if typepy.is_null_string(table_name):
#             raise InvalidTableNameError("table name is empty after the template replacement")
# 
#         return table_name.strip("_")
# 
#     @classmethod
#     def clear_table_count(cls):
#         with cls.__table_count_lock:
#             cls.__global_table_count = 0
#             cls.__format_table_count = {}
# 
# Path: pytablereader/markdown/formatter.py
# class MarkdownTableFormatter(HtmlTableFormatter):
#     def __init__(self, source_data, logger=None):
#         import markdown
# 
#         if typepy.is_null_string(source_data):
#             raise DataError
# 
#         super().__init__(
#             markdown.markdown(source_data, extensions=["markdown.extensions.tables"]), logger=logger
#         )


import collections
import pytest
import pytablereader as ptr
from textwrap import dedent
from path import Path
from pytablewriter import dumps_tabledata
from tabledata import TableData
from pytablereader.interface import AbstractTableReader
from pytablereader.markdown.formatter import MarkdownTableFormatter

        assert load

    @pytest.mark.parametrize(
        ["table_text", "filename"], [[test_empty_data_00, "tmp.md"], [test_empty_data_01, "tmp.md"]]
    )
    def test_normal_empty_data(self, tmpdir, table_text, filename):
        p_file_path = tmpdir.join(filename)

        with open(str(p_file_path), "w") as f:
            f.write(table_text)

        loader = ptr.MarkdownTableFileLoader(str(p_file_path))

        for _tabletuple in loader.load():
            raise ValueError("should not reach this line")

    @pytest.mark.parametrize(
        ["filename", "expected"], [["", ptr.InvalidFilePathError], [None, ptr.InvalidFilePathError]]
    )
    def test_exception(self, tmpdir, filename, expected):
        loader = ptr.MarkdownTableFileLoader(filename)

        with pytest.raises(expected):
            for _tabletuple in loader.load():
                pass


class Test_MarkdownTableTextLoader_load:
    def setup_method(self, method):

# Path: pytablereader/interface.py
# class AbstractTableReader(TableLoaderInterface, metaclass=abc.ABCMeta):
#     """
#     The abstract class of table data file loader.
# 
#     .. py:attribute:: table_name
# 
#         Table name string.
# 
#     .. py:attribute:: source
# 
#         Table data source to load.
#     """
# 
#     __table_count_lock = threading.Lock()
#     __global_table_count = 0
#     __format_table_count = {}
# 
#     @property
#     def source_type(self):
#         return self._validator.source_type
# 
#     @property
#     def quoting_flags(self):
#         return self.__quoting_flags
# 
#     @property
#     def dp_extractor(self):
#         return self.__dp_extractor
# 
#     def __init__(self, source, quoting_flags, type_hints, type_hint_rules=None):
#         self.table_name = tnt.DEFAULT
#         self.source = source
#         self.__quoting_flags = quoting_flags
#         self.type_hints = type_hints
#         self.type_hint_rules = type_hint_rules
#         self._validator = None
#         self._logger = None
# 
#         self.__dp_extractor = DataPropertyExtractor()
#         self.__dp_extractor.quoting_flags = self.quoting_flags
#         self.__dp_extractor.update_strict_level_map({typepy.Typecode.BOOL: 1})
# 
#     def get_format_key(self):
#         return f"{self.format_name:s}{self.__get_format_table_count():d}"
# 
#     def make_table_name(self):
#         return self._make_table_name()
# 
#     def inc_table_count(self):
#         with self.__table_count_lock:
#             self.__global_table_count += 1
#             self.__format_table_count[self.format_name] = self.__get_format_table_count() + 1
# 
#     @abc.abstractmethod
#     def _get_default_table_name_template(self):  # pragma: no cover
#         pass
# 
#     def _validate(self):
#         self._validate_table_name()
#         self._validate_source()
# 
#     def _validate_table_name(self):
#         try:
#             if typepy.is_null_string(self.table_name):
#                 raise ValueError("table name is empty")
#         except (TypeError, AttributeError):
#             raise TypeError("table_name must be a string")
# 
#     def _validate_source(self):
#         self._validator.validate()
# 
#     def __get_format_table_count(self):
#         return self.__format_table_count.get(self.format_name, 0)
# 
#     def _get_filename_tablename_mapping(self):
#         filename = ""
#         if all([self.source_type == SourceType.FILE, typepy.is_not_null_string(self.source)]):
#             filename = path.Path(self.source).stem
# 
#         return (tnt.FILENAME, filename)
# 
#     def _get_basic_tablename_keyvalue_mapping(self):
#         from collections import OrderedDict
# 
#         return OrderedDict(
#             [
#                 (tnt.DEFAULT, self._get_default_table_name_template()),
#                 (tnt.FORMAT_NAME, self.format_name),
#                 (tnt.FORMAT_ID, str(self.__get_format_table_count())),
#                 (tnt.GLOBAL_ID, str(self.__global_table_count)),
#                 self._get_filename_tablename_mapping(),
#             ]
#         )
# 
#     def _expand_table_name_format(self, table_name_kv_mapping):
#         self._validate_table_name()
# 
#         table_name = self.table_name
#         for template, value in table_name_kv_mapping.items():
#             table_name = table_name.replace(template, value)
# 
#         return self._sanitize_table_name(table_name)
# 
#     def _make_table_name(self):
#         self._validate_table_name()
# 
#         return self._expand_table_name_format(self._get_basic_tablename_keyvalue_mapping())
# 
#     @staticmethod
#     def _sanitize_table_name(table_name):
#         if typepy.is_null_string(table_name):
#             raise InvalidTableNameError("table name is empty after the template replacement")
# 
#         return table_name.strip("_")
# 
#     @classmethod
#     def clear_table_count(cls):
#         with cls.__table_count_lock:
#             cls.__global_table_count = 0
#             cls.__format_table_count = {}
# 
# Path: pytablereader/markdown/formatter.py
# class MarkdownTableFormatter(HtmlTableFormatter):
#     def __init__(self, source_data, logger=None):
#         import markdown
# 
#         if typepy.is_null_string(source_data):
#             raise DataError
# 
#         super().__init__(
#             markdown.markdown(source_data, extensions=["markdown.extensions.tables"]), logger=logger
#         )


# Path: test/test_markdown_reader.py
import collections
import pytest
import pytablereader as ptr
from textwrap import dedent
from path import Path
from pytablewriter import dumps_tabledata
from tabledata import TableData
from pytablereader.interface import AbstractTableReader
from pytablereader.markdown.formatter import MarkdownTableFormatter


        assert load

    @pytest.mark.parametrize(
        ["table_text", "filename"], [[test_empty_data_00, "tmp.md"], [test_empty_data_01, "tmp.md"]]
    )
    def test_normal_empty_data(self, tmpdir, table_text, filename):
        p_file_path = tmpdir.join(filename)

        with open(str(p_file_path), "w") as f:
            f.write(table_text)

        loader = ptr.MarkdownTableFileLoader(str(p_file_path))

        for _tabletuple in loader.load():
            raise ValueError("should not reach this line")

    @pytest.mark.parametrize(
        ["filename", "expected"], [["", ptr.InvalidFilePathError], [None, ptr.InvalidFilePathError]]
    )
    def test_exception(self, tmpdir, filename, expected):
        loader = ptr.MarkdownTableFileLoader(filename)

        with pytest.raises(expected):
            for _tabletuple in loader.load():
                pass


class Test_MarkdownTableTextLoader_load:
    def setup_method(self, method):

        AbstractTableReader.clear_table_count()