How to use the normality.paths.safe_filename function in normality

To help you get started, we’ve selected a few normality examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pudo / normality / tests / test_paths.py View on Github external
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'))
github pudo / normality / tests / test_paths.py View on Github external
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'))
github pudo / normality / tests / test_paths.py View on Github external
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
github pudo / normality / tests / test_paths.py View on Github external
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'))
github pudo / normality / tests / test_paths.py View on Github external
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
github pudo / normality / tests / test_paths.py View on Github external
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'))
github pudo / normality / tests / test_paths.py View on Github external
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'))
github pudo / normality / tests / test_paths.py View on Github external
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'))
github pudo / normality / tests / test_paths.py View on Github external
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
github pudo / normality / tests / test_paths.py View on Github external
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'))