diff --git a/tests/test_error.py b/tests/test_error.py index 72446267..6e736330 100644 --- a/tests/test_error.py +++ b/tests/test_error.py @@ -2,6 +2,7 @@ # SPDX-FileCopyrightText: 2021 Taneli Hukkinen # Licensed to PSF under a Contributor Agreement. +import io import unittest from . import tomllib @@ -55,3 +56,11 @@ def list_returner(s: str) -> list: self.assertEqual( str(exc_info.exception), "parse_float must not return dicts or lists" ) + + def test_text_mode_error(self): + with self.assertRaises(TypeError) as exc_info: + tomllib.load(io.StringIO()) # type: ignore[arg-type] + self.assertEqual( + str(exc_info.exception), + "File must be opened in binary mode, e.g. use `open('foo.toml', 'rb')`", + )