aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2024-10-25 17:27:30 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2024-10-25 17:27:30 -0400
commitfc004701f923bb954a22c7fec2ae8d607e78cb2b (patch)
treea5bea4ed6447ea43c099131430e3bd6182ee87d7 /test
parent0db541f524e1774865efebcbe5653e9ad76ea2e8 (diff)
New upstream version 1.27.7.upstream/1.27.7
Diffstat (limited to 'test')
-rw-r--r--test/test_results.py2
-rw-r--r--test/test_util.py36
2 files changed, 32 insertions, 6 deletions
diff --git a/test/test_results.py b/test/test_results.py
index ed9c9a9..f36f798 100644
--- a/test/test_results.py
+++ b/test/test_results.py
@@ -358,7 +358,7 @@ class TestPathfmt():
def __enter__(self):
return self
- def __exit__(self, *args):
+ def __exit__(self, exc_type, exc_value, traceback):
pass
def open(self, mode):
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"