MCPcopy
hub / github.com/django/django / test_get_valid_filename

Method test_get_valid_filename

tests/utils_tests/test_text.py:395–405  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

393 text.unescape_string_literal(item)
394
395 def test_get_valid_filename(self):
396 filename = "^&'@{}[],$=!-#()%+~_123.txt"
397 self.assertEqual(text.get_valid_filename(filename), "-_123.txt")
398 self.assertEqual(text.get_valid_filename(lazystr(filename)), "-_123.txt")
399 msg = "Could not derive file name from '???'"
400 with self.assertRaisesMessage(SuspiciousFileOperation, msg):
401 text.get_valid_filename("???")
402 # After sanitizing this would yield '..'.
403 msg = "Could not derive file name from '$.$.$'"
404 with self.assertRaisesMessage(SuspiciousFileOperation, msg):
405 text.get_valid_filename("$.$.$")
406
407 def test_compress_sequence(self):
408 data = [{"key": i} for i in range(100)]

Callers

nothing calls this directly

Calls 2

lazystrFunction · 0.90
assertRaisesMessageMethod · 0.80

Tested by

no test coverage detected