Skip to content

Commit

Permalink
Add test coverage for text mode error
Browse files Browse the repository at this point in the history
Error message was added in #175
  • Loading branch information
hauntsaninja committed Oct 2, 2024
1 parent facdab0 commit 7ae8eb5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-FileCopyrightText: 2021 Taneli Hukkinen
# Licensed to PSF under a Contributor Agreement.

import io
import unittest

from . import tomllib
Expand Down Expand Up @@ -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')`",
)

0 comments on commit 7ae8eb5

Please sign in to comment.