Skip to content

Commit

Permalink
Make TOMLDecodeError show 'tomli' as its module (#135)
Browse files Browse the repository at this point in the history
* Make TOMLDecodeError show 'tomli' as its module

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Move __module__ assignment to __init__, add test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
goodmami and pre-commit-ci[bot] committed Oct 22, 2021
1 parent 8917fe3 commit 96dfe2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/test_error.py
Expand Up @@ -31,3 +31,7 @@ def test_invalid_char_quotes():
with pytest.raises(tomli.TOMLDecodeError) as exc_info:
tomli.loads("v = '\n'")
assert " '\\n' " in str(exc_info.value)


def test_module_name():
assert tomli.TOMLDecodeError().__module__ == "tomli"
3 changes: 3 additions & 0 deletions tomli/__init__.py
Expand Up @@ -4,3 +4,6 @@
__version__ = "1.2.1" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT

from tomli._parser import TOMLDecodeError, load, loads

# Pretend this exception was created here.
TOMLDecodeError.__module__ = "tomli"

0 comments on commit 96dfe2c

Please sign in to comment.