Added test for ValueErrors in unescape_string_literal().

This commit is contained in:
Florian Apolloner 2021-12-14 20:16:41 +01:00 committed by Mariusz Felisiak
parent 3b73f77ad4
commit 5d9c512e5b
1 changed files with 7 additions and 0 deletions

View File

@ -225,6 +225,13 @@ class TestUtilsText(SimpleTestCase):
self.assertEqual(text.unescape_string_literal(value), output)
self.assertEqual(text.unescape_string_literal(lazystr(value)), output)
def test_unescape_string_literal_invalid_value(self):
items = ['abc', "'abc\""]
for item in items:
msg = f'Not a string literal: {item!r}'
with self.assertRaisesMessage(ValueError, msg):
text.unescape_string_literal(item)
def test_get_valid_filename(self):
filename = "^&'@{}[],$=!-#()%+~_123.txt"
self.assertEqual(text.get_valid_filename(filename), "-_123.txt")