summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_http_cookiejar.py
diff options
context:
space:
mode:
authorStéphane Wirtel <stephane@wirtel.be>2019-03-01 20:40:54 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-03-01 20:40:54 (GMT)
commit4b219ce81ed04234648a4ce4f0cb0865818abb38 (patch)
tree43d7c14161d763c8d257af45b95e4463cea854dd /Lib/test/test_http_cookiejar.py
parentbda918bf65a88560ec453aaba0758a9c0d49b449 (diff)
downloadcpython-4b219ce81ed04234648a4ce4f0cb0865818abb38.zip
cpython-4b219ce81ed04234648a4ce4f0cb0865818abb38.tar.gz
cpython-4b219ce81ed04234648a4ce4f0cb0865818abb38.tar.bz2
bpo-36043: FileCookieJar supports os.PathLike (GH-11945)
https://bugs.python.org/issue36043
Diffstat (limited to 'Lib/test/test_http_cookiejar.py')
-rw-r--r--Lib/test/test_http_cookiejar.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_http_cookiejar.py b/Lib/test/test_http_cookiejar.py
index 8dbea33..170549c 100644
--- a/Lib/test/test_http_cookiejar.py
+++ b/Lib/test/test_http_cookiejar.py
@@ -6,6 +6,7 @@ import test.support
import time
import unittest
import urllib.request
+import pathlib
from http.cookiejar import (time2isoz, http2time, iso2time, time2netscape,
parse_ns_headers, join_header_words, split_header_words, Cookie,
@@ -313,6 +314,30 @@ def _interact(cookiejar, url, set_cookie_hdrs, hdr_name):
class FileCookieJarTests(unittest.TestCase):
+ def test_constructor_with_str(self):
+ filename = test.support.TESTFN
+ c = LWPCookieJar(filename)
+ self.assertEqual(c.filename, filename)
+
+ def test_constructor_with_path_like(self):
+ filename = pathlib.Path(test.support.TESTFN)
+ c = LWPCookieJar(filename)
+ self.assertEqual(c.filename, os.fspath(filename))
+
+ def test_constructor_with_none(self):
+ c = LWPCookieJar(None)
+ self.assertIsNone(c.filename)
+
+ def test_constructor_with_other_types(self):
+ class A:
+ pass
+
+ for type_ in (int, float, A):
+ with self.subTest(filename=type_):
+ with self.assertRaises(TypeError):
+ instance = type_()
+ c = LWPCookieJar(filename=instance)
+
def test_lwp_valueless_cookie(self):
# cookies with no value should be saved and loaded consistently
filename = test.support.TESTFN