diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/test_config.py | 12 | ||||
| -rw-r--r-- | test/test_cookies.py | 8 | ||||
| -rw-r--r-- | test/test_downloader.py | 8 | ||||
| -rw-r--r-- | test/test_formatter.py | 12 | ||||
| -rw-r--r-- | test/test_results.py | 1 | ||||
| -rw-r--r-- | test/test_util.py | 12 |
6 files changed, 38 insertions, 15 deletions
diff --git a/test/test_config.py b/test/test_config.py index 06780be..bbe288f 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -165,12 +165,12 @@ class TestConfig(unittest.TestCase): def test_load(self): with tempfile.TemporaryDirectory() as base: path1 = os.path.join(base, "cfg1") - with open(path1, "w") as file: - file.write('{"a": 1, "b": {"a": 2, "c": "text"}}') + with open(path1, "w") as fp: + fp.write('{"a": 1, "b": {"a": 2, "c": "text"}}') path2 = os.path.join(base, "cfg2") - with open(path2, "w") as file: - file.write('{"a": 7, "b": {"a": 8, "e": "foo"}}') + with open(path2, "w") as fp: + fp.write('{"a": 7, "b": {"a": 8, "e": "foo"}}') config.clear() config.load((path1,)) @@ -208,8 +208,8 @@ class TestConfigFiles(unittest.TestCase): def _load(name): path = os.path.join(ROOTDIR, "docs", name) try: - with open(path) as file: - return util.json_loads(file.read()) + with open(path) as fp: + return util.json_loads(fp.read()) except FileNotFoundError: raise unittest.SkipTest(path + " not available") diff --git a/test/test_cookies.py b/test/test_cookies.py index 208645d..60c83ff 100644 --- a/test/test_cookies.py +++ b/test/test_cookies.py @@ -28,14 +28,14 @@ class TestCookiejar(unittest.TestCase): cls.path = tempfile.TemporaryDirectory() cls.cookiefile = join(cls.path.name, "cookies.txt") - with open(cls.cookiefile, "w") as file: - file.write("""# HTTP Cookie File + with open(cls.cookiefile, "w") as fp: + fp.write("""# HTTP Cookie File .example.org\tTRUE\t/\tFALSE\t253402210800\tNAME\tVALUE """) cls.invalid_cookiefile = join(cls.path.name, "invalid.txt") - with open(cls.invalid_cookiefile, "w") as file: - file.write("""# asd + with open(cls.invalid_cookiefile, "w") as fp: + fp.write("""# asd .example.org\tTRUE/FALSE\t253402210800\tNAME\tVALUE """) diff --git a/test/test_downloader.py b/test/test_downloader.py index 9f9fb3b..f88b2c0 100644 --- a/test/test_downloader.py +++ b/test/test_downloader.py @@ -136,8 +136,8 @@ class TestDownloaderBase(unittest.TestCase): if content: mode = "w" + ("b" if isinstance(content, bytes) else "") - with pathfmt.open(mode) as file: - file.write(content) + with pathfmt.open(mode) as fp: + fp.write(content) return pathfmt @@ -151,8 +151,8 @@ class TestDownloaderBase(unittest.TestCase): # test content mode = "r" + ("b" if isinstance(output, bytes) else "") - with pathfmt.open(mode) as file: - content = file.read() + with pathfmt.open(mode) as fp: + content = fp.read() self.assertEqual(content, output) # test filename extension diff --git a/test/test_formatter.py b/test/test_formatter.py index 73e958c..e00af85 100644 --- a/test/test_formatter.py +++ b/test/test_formatter.py @@ -267,6 +267,18 @@ class TestFormatter(unittest.TestCase): "{a:Sort-reverse}", # starts with 'S', contains 'r' "['w', 'r', 'o', 'l', 'h', 'd', 'O', 'L', 'L', 'E', ' ']") + def test_specifier_conversions(self): + self._run_test("{a:Cl}" , "hello world") + self._run_test("{h:CHC}" , "Foo & Bar") + self._run_test("{l:CSulc}", "A, b, c") + + def test_specifier_limit(self): + self._run_test("{a:X20/ */}", "hElLo wOrLd") + self._run_test("{a:X10/ */}", "hElLo wO *") + + with self.assertRaises(ValueError): + self._run_test("{a:Xfoo/ */}", "hello wo *") + def test_chain_special(self): # multiple replacements self._run_test("{a:Rh/C/RE/e/RL/l/}", "Cello wOrld") diff --git a/test/test_results.py b/test/test_results.py index aaa71ec..ab3668e 100644 --- a/test/test_results.py +++ b/test/test_results.py @@ -25,7 +25,6 @@ from test import results # noqa E402 # temporary issues, etc. BROKEN = { - "photobucket", } CONFIG = { diff --git a/test/test_util.py b/test/test_util.py index 83b44b7..35e7247 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -745,6 +745,7 @@ def hash(value): self.assertEqual(repr(obj), repr(None)) self.assertEqual(format(obj), str(None)) self.assertEqual(format(obj, "%F"), str(None)) + self.assertIs(obj.attr, obj) self.assertIs(obj["key"], obj) self.assertIs(obj(), obj) @@ -752,6 +753,17 @@ def hash(value): self.assertIs(obj(foo="bar"), obj) self.assertEqual(util.json_dumps(obj), "null") + self.assertLess(obj, "foo") + self.assertLessEqual(obj, None) + self.assertFalse(obj == obj) + self.assertTrue(obj != obj) + self.assertGreater(123, obj) + self.assertGreaterEqual(1.23, obj) + + mapping = {} + mapping[obj] = 123 + self.assertIn(obj, mapping) + i = 0 for _ in obj: i += 1 |
