Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_safe_filename(self):
self.assertEqual(None, safe_filename(None))
self.assertEqual('test.txt', safe_filename('test.txt'))
self.assertEqual('test.txt', safe_filename('test .txt'))
self.assertEqual('test_bla.txt', safe_filename('test bla.txt'))
self.assertEqual('test_bla.txt', safe_filename('test_bla.txt'))
self.assertEqual('test_bla.txt', safe_filename('test.bla.txt'))
self.assertEqual('test.txt', safe_filename('test', extension='txt'))
def test_safe_filename(self):
self.assertEqual(None, safe_filename(None))
self.assertEqual('test.txt', safe_filename('test.txt'))
self.assertEqual('test.txt', safe_filename('test .txt'))
self.assertEqual('test_bla.txt', safe_filename('test bla.txt'))
self.assertEqual('test_bla.txt', safe_filename('test_bla.txt'))
self.assertEqual('test_bla.txt', safe_filename('test.bla.txt'))
self.assertEqual('test.txt', safe_filename('test', extension='txt'))
def test_long_filename(self):
long_name = ['long name'] * 100
long_name = '-'.join(long_name)
shortened = safe_filename(long_name)
assert len(shortened) <= MAX_LENGTH, shortened
shortened = safe_filename(long_name, extension='html')
assert len(shortened) <= MAX_LENGTH, shortened
shortened = safe_filename('bla', extension=long_name)
assert len(shortened) <= MAX_LENGTH, shortened
shortened = safe_filename(long_name, extension=long_name)
assert len(shortened) <= MAX_LENGTH, shortened
def test_safe_filename(self):
self.assertEqual(None, safe_filename(None))
self.assertEqual('test.txt', safe_filename('test.txt'))
self.assertEqual('test.txt', safe_filename('test .txt'))
self.assertEqual('test_bla.txt', safe_filename('test bla.txt'))
self.assertEqual('test_bla.txt', safe_filename('test_bla.txt'))
self.assertEqual('test_bla.txt', safe_filename('test.bla.txt'))
self.assertEqual('test.txt', safe_filename('test', extension='txt'))
def test_long_filename(self):
long_name = ['long name'] * 100
long_name = '-'.join(long_name)
shortened = safe_filename(long_name)
assert len(shortened) <= MAX_LENGTH, shortened
shortened = safe_filename(long_name, extension='html')
assert len(shortened) <= MAX_LENGTH, shortened
shortened = safe_filename('bla', extension=long_name)
assert len(shortened) <= MAX_LENGTH, shortened
shortened = safe_filename(long_name, extension=long_name)
assert len(shortened) <= MAX_LENGTH, shortened
def test_safe_filename(self):
self.assertEqual(None, safe_filename(None))
self.assertEqual('test.txt', safe_filename('test.txt'))
self.assertEqual('test.txt', safe_filename('test .txt'))
self.assertEqual('test_bla.txt', safe_filename('test bla.txt'))
self.assertEqual('test_bla.txt', safe_filename('test_bla.txt'))
self.assertEqual('test_bla.txt', safe_filename('test.bla.txt'))
self.assertEqual('test.txt', safe_filename('test', extension='txt'))
def test_safe_filename(self):
self.assertEqual(None, safe_filename(None))
self.assertEqual('test.txt', safe_filename('test.txt'))
self.assertEqual('test.txt', safe_filename('test .txt'))
self.assertEqual('test_bla.txt', safe_filename('test bla.txt'))
self.assertEqual('test_bla.txt', safe_filename('test_bla.txt'))
self.assertEqual('test_bla.txt', safe_filename('test.bla.txt'))
self.assertEqual('test.txt', safe_filename('test', extension='txt'))
def test_safe_filename(self):
self.assertEqual(None, safe_filename(None))
self.assertEqual('test.txt', safe_filename('test.txt'))
self.assertEqual('test.txt', safe_filename('test .txt'))
self.assertEqual('test_bla.txt', safe_filename('test bla.txt'))
self.assertEqual('test_bla.txt', safe_filename('test_bla.txt'))
self.assertEqual('test_bla.txt', safe_filename('test.bla.txt'))
self.assertEqual('test.txt', safe_filename('test', extension='txt'))
def test_long_filename(self):
long_name = ['long name'] * 100
long_name = '-'.join(long_name)
shortened = safe_filename(long_name)
assert len(shortened) <= MAX_LENGTH, shortened
shortened = safe_filename(long_name, extension='html')
assert len(shortened) <= MAX_LENGTH, shortened
shortened = safe_filename('bla', extension=long_name)
assert len(shortened) <= MAX_LENGTH, shortened
shortened = safe_filename(long_name, extension=long_name)
assert len(shortened) <= MAX_LENGTH, shortened
def test_safe_filename(self):
self.assertEqual(None, safe_filename(None))
self.assertEqual('test.txt', safe_filename('test.txt'))
self.assertEqual('test.txt', safe_filename('test .txt'))
self.assertEqual('test_bla.txt', safe_filename('test bla.txt'))
self.assertEqual('test_bla.txt', safe_filename('test_bla.txt'))
self.assertEqual('test_bla.txt', safe_filename('test.bla.txt'))
self.assertEqual('test.txt', safe_filename('test', extension='txt'))