aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_util.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2024-10-25 17:27:36 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2024-10-25 17:27:36 -0400
commita46d8cec37ef1e7370a3127dd5bf3a47e7dc40de (patch)
tree27382aedd6d14d1add2b1a37e6df2f3e52f0ac4e /test/test_util.py
parente4f39ad7148b104ab522ee13e4af3d3003b65e0f (diff)
parentfc004701f923bb954a22c7fec2ae8d607e78cb2b (diff)
Update upstream source from tag 'upstream/1.27.7'
Update to upstream version '1.27.7' with Debian dir f4e7d47b82b8fc4fb17fad4aa54873015dcc81c1
Diffstat (limited to 'test/test_util.py')
-rw-r--r--test/test_util.py36
1 files changed, 31 insertions, 5 deletions
diff --git a/test/test_util.py b/test/test_util.py
index e2db29b..888a70a 100644
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -205,9 +205,8 @@ class TestCookiesTxt(unittest.TestCase):
def test_cookiestxt_load(self):
def _assert(content, expected):
- jar = http.cookiejar.CookieJar()
- util.cookiestxt_load(io.StringIO(content, None), jar)
- for c, e in zip(jar, expected):
+ cookies = util.cookiestxt_load(io.StringIO(content, None))
+ for c, e in zip(cookies, expected):
self.assertEqual(c.__dict__, e.__dict__)
_assert("", [])
@@ -253,8 +252,7 @@ class TestCookiesTxt(unittest.TestCase):
)
with self.assertRaises(ValueError):
- util.cookiestxt_load("example.org\tTRUE\t/\tTRUE\t0\tname",
- http.cookiejar.CookieJar())
+ util.cookiestxt_load("example.org\tTRUE\t/\tTRUE\t0\tname")
def test_cookiestxt_store(self):
@@ -832,6 +830,34 @@ def hash(value):
i += 1
self.assertEqual(i, 0)
+ def test_module_proxy(self):
+ proxy = util.ModuleProxy()
+
+ self.assertIs(proxy.os, os)
+ self.assertIs(proxy.os.path, os.path)
+ self.assertIs(proxy["os"], os)
+ self.assertIs(proxy["os.path"], os.path)
+ self.assertIs(proxy["os"].path, os.path)
+
+ self.assertIs(proxy.abcdefghi, util.NONE)
+ self.assertIs(proxy["abcdefghi"], util.NONE)
+ self.assertIs(proxy["abc.def.ghi"], util.NONE)
+ self.assertIs(proxy["os.path2"], util.NONE)
+
+ def test_null_context(self):
+ with util.NullContext():
+ pass
+
+ with util.NullContext() as ctx:
+ self.assertIs(ctx, None)
+
+ try:
+ with util.NullContext() as ctx:
+ exc_orig = ValueError()
+ raise exc_orig
+ except ValueError as exc:
+ self.assertIs(exc, exc_orig)
+
class TestExtractor():
category = "test_category"