diff options
author | Florian Bruhin <me@the-compiler.org> | 2022-05-20 11:01:46 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2022-05-20 11:01:46 +0200 |
commit | 15dc5e81f7287758699c8a90502eceb41f375012 (patch) | |
tree | bb066bad5454dfcdefce45d81d2ccaba18ee657c | |
parent | 409a2990a84d5b7402b82b6ca3f8fc99bcc1dd84 (diff) | |
download | qutebrowser-15dc5e81f7287758699c8a90502eceb41f375012.tar.gz qutebrowser-15dc5e81f7287758699c8a90502eceb41f375012.zip |
tests: Improve TestSanitizeFilename
Those special cases were only tested by Hypothesis before
-rw-r--r-- | tests/unit/utils/test_utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py index 4620c2198..faced4943 100644 --- a/tests/unit/utils/test_utils.py +++ b/tests/unit/utils/test_utils.py @@ -603,6 +603,15 @@ class TestSanitizeFilename: LONG_EXTENSION = (LONG_FILENAME.replace("filename", ".extension") .replace(".txt", "")) + # first four-byte unicode char + U10K = "\U00010000" + + LONG_4BYTE = U10K * 64 + LONG_4BYTE_SHORTENED = U10K * 60 + + LONG_4BYTE_EXT = f"{U10K * 8}.{U10K * 64}" + LONG_4BYTE_EXT_SHORTENED = f"{U10K}.{U10K * 59}" + @pytest.mark.parametrize('inp, expected', [ pytest.param('normal.txt', 'normal.txt', marks=pytest.mark.fake_os('windows')), @@ -629,6 +638,14 @@ class TestSanitizeFilename: LONG_EXTENSION.replace("this is a very long .extension", "this .extension"), ), + ( + LONG_4BYTE, + LONG_4BYTE_SHORTENED, + ), + ( + LONG_4BYTE_EXT, + LONG_4BYTE_EXT_SHORTENED, + ) ]) @pytest.mark.linux def test_shorten(self, inp, expected): |