Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in

Unified Diff: Lib/test/test_imghdr.py

Issue 28228: imghdr does not support pathlib
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/imghdr.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_imghdr.py
+++ b/Lib/test/test_imghdr.py
@@ -1,11 +1,12 @@
import imghdr
import io
import os
+import pathlib
import unittest
import warnings
from test.support import findfile, TESTFN, unlink
('python.png', 'png'),
('python.gif', 'gif'),
('python.bmp', 'bmp'),
@@ -44,16 +45,22 @@ class TestImghdr(unittest.TestCase):
self.assertEqual(imghdr.what(filename), expected)
with open(filename, 'rb') as stream:
self.assertEqual(imghdr.what(stream), expected)
with open(filename, 'rb') as stream:
data = stream.read()
self.assertEqual(imghdr.what(None, data), expected)
self.assertEqual(imghdr.what(None, bytearray(data)), expected)
+ def test_pathlike_filename(self):
+ for filename, expected in TEST_FILES:
+ with self.subTest(filename=filename):
+ filename = findfile(filename, subdir='imghdrdata')
+ self.assertEqual(imghdr.what(pathlib.Path(filename)), expected)
def test_register_test(self):
def test_jumbo(h, file):
if h.startswith(b'eggs'):
return 'ham'
self.assertEqual(imghdr.what(None, b'eggs'), 'ham')
« no previous file with comments | « Lib/imghdr.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+