aboutsummaryrefslogtreecommitdiff
path: root/test/test_util.py
diff options
context:
space:
mode:
authorSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 13:19:39 -0700
committerSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 13:19:39 -0700
commit54bdd56778a37ea9d56d451d4ae49b99cbbfceaa (patch)
tree3b69a7371b29898f08ced7514b42bad8afdc8759 /test/test_util.py
parent0f393d00b51bc54c5075447e4a8b21f0bed6acd8 (diff)
downloadpython-urllib3-54bdd56778a37ea9d56d451d4ae49b99cbbfceaa.tar
python-urllib3-54bdd56778a37ea9d56d451d4ae49b99cbbfceaa.tar.gz
Imported Upstream version 1.9.1
Diffstat (limited to 'test/test_util.py')
-rw-r--r--test/test_util.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/test_util.py b/test/test_util.py
index 388d877..1811dbd 100644
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -21,6 +21,8 @@ from urllib3.exceptions import (
InsecureRequestWarning,
)
+from urllib3.util import is_fp_closed
+
from . import clear_warnings
# This number represents a time in seconds, it doesn't mean anything in
@@ -324,3 +326,32 @@ class TestUtil(unittest.TestCase):
self.assertEqual(resolve_cert_reqs('REQUIRED'), ssl.CERT_REQUIRED)
self.assertEqual(resolve_cert_reqs('CERT_REQUIRED'), ssl.CERT_REQUIRED)
+ def test_is_fp_closed_object_supports_closed(self):
+ class ClosedFile(object):
+ @property
+ def closed(self):
+ return True
+
+ self.assertTrue(is_fp_closed(ClosedFile()))
+
+ def test_is_fp_closed_object_has_none_fp(self):
+ class NoneFpFile(object):
+ @property
+ def fp(self):
+ return None
+
+ self.assertTrue(is_fp_closed(NoneFpFile()))
+
+ def test_is_fp_closed_object_has_fp(self):
+ class FpFile(object):
+ @property
+ def fp(self):
+ return True
+
+ self.assertTrue(not is_fp_closed(FpFile()))
+
+ def test_is_fp_closed_object_has_neither_fp_nor_closed(self):
+ class NotReallyAFile(object):
+ pass
+
+ self.assertRaises(ValueError, is_fp_closed, NotReallyAFile())