diff options
Diffstat (limited to 'test/test_util.py')
| -rw-r--r-- | test/test_util.py | 36 |
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" |
