Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions tabulate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from decimal import Decimal
from functools import partial, reduce
from html import escape as htmlescape
from importlib.metadata import PackageNotFoundError, version
import io
from itertools import chain, zip_longest as izip_longest
import math
Expand All @@ -21,12 +20,15 @@
except ImportError:
wcwidth = None


try:
__version__ = version("tabulate") # installed package
except PackageNotFoundError:
from ._version import version as __version__ # generated by flit_scm / setuptools_scm
except ImportError:
from importlib.metadata import PackageNotFoundError, version

try:
from ._version import version as __version__ # editable / source checkout
except ImportError:
__version__ = version("tabulate")
except PackageNotFoundError:
__version__ = "unknown"


Expand Down
8 changes: 7 additions & 1 deletion test/test_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""API properties."""

from tabulate import simple_separated_format, tabulate, tabulate_formats
from tabulate import __version__, simple_separated_format, tabulate, tabulate_formats

from common import skip

Expand All @@ -11,6 +11,12 @@
_empty = None


def test_tabulate_version():
"API: __version__ is a non-empty string"
assert type(__version__) is str
assert len(__version__) > 0


def test_tabulate_formats():
"API: tabulate_formats is a list of strings"
supported = tabulate_formats
Expand Down