mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 01:04:29 +03:00
Merge pull request #3616 from wbadart/master
_util.isPath returns True for pathlib.Path objects
This commit is contained in:
commit
8cd0432e65
|
@ -35,6 +35,18 @@ class TestUtil(PillowTestCase):
|
|||
# Assert
|
||||
self.assertTrue(it_is)
|
||||
|
||||
@unittest.skipIf(not _util.py36, 'os.path support for Paths added in 3.6')
|
||||
def test_path_obj_is_path(self):
|
||||
# Arrange
|
||||
from pathlib import Path
|
||||
test_path = Path('filename.ext')
|
||||
|
||||
# Act
|
||||
it_is = _util.isPath(test_path)
|
||||
|
||||
# Assert
|
||||
self.assertTrue(it_is)
|
||||
|
||||
def test_is_not_path(self):
|
||||
# Arrange
|
||||
filename = self.tempfile("temp.ext")
|
||||
|
|
|
@ -2,13 +2,20 @@ import os
|
|||
import sys
|
||||
|
||||
py3 = sys.version_info.major >= 3
|
||||
py36 = sys.version_info[0:2] >= (3, 6)
|
||||
|
||||
if py3:
|
||||
def isStringType(t):
|
||||
return isinstance(t, str)
|
||||
|
||||
def isPath(f):
|
||||
return isinstance(f, (bytes, str))
|
||||
if py36:
|
||||
from pathlib import Path
|
||||
|
||||
def isPath(f):
|
||||
return isinstance(f, (bytes, str, Path))
|
||||
else:
|
||||
def isPath(f):
|
||||
return isinstance(f, (bytes, str))
|
||||
else:
|
||||
def isStringType(t):
|
||||
return isinstance(t, basestring) # noqa: F821
|
||||
|
|
Loading…
Reference in New Issue
Block a user