Skip to content
Snippets Groups Projects
Commit 23afb8a9 authored by Michael Williamson's avatar Michael Williamson
Browse files

Test filename is included in parse errors

parent 0495b019
No related branches found
No related tags found
No related merge requests found
from __future__ import unicode_literals
import sys
if sys.version_info < (2, 7):
from StringIO import StringIO
else:
from io import StringIO
import pytest
import pytoml as toml
def test_name_of_fileobj_is_used_in_errors():
source = StringIO("[")
source.name = "<source>"
error = pytest.raises(toml.TomlError, lambda: toml.load(source))
assert error.value.filename == "<source>"
def test_when_fileobj_has_no_name_attr_then_repr_of_fileobj_is_used_in_errors():
source = StringIO("[")
error = pytest.raises(toml.TomlError, lambda: toml.load(source))
assert error.value.filename == repr(source)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment