Beispiel #1
0
    def test_windows_invalid_characters(self):
        '''Test whether a Windows filename containing invalid characters is invalid'''
        fs = SystemFS()

        for i in xrange(30):
            self.assertFalse(fs.validateFilename('abc%s.txt' % chr(i), platform=PlatformType.WIN))

        for c in ('<', '>', ':', '"', '/', '\\', '|', '?', '*', ):
            self.assertFalse(fs.validateFilename('abc%s.txt' % c, platform=PlatformType.WIN))
Beispiel #2
0
 def test_windows_invalid_basenames(self):
     '''Test whether Windows filenames using a DOS device as basename are invalid'''
     fs = SystemFS()
     invalids = itertools.chain(('CON', 'PRN', 'AUX', 'CLOCK$', 'NUL', ),
                                ('COM%d' % i for i in xrange(1, 9)),
                                ('LPT%d' % i for i in xrange(1, 9))
                               )
     for invalid in invalids:
         self.assertFalse(fs.validateFilename('%s.txt' % invalid, platform=PlatformType.WIN))
Beispiel #3
0
 def test_windows_invalid_ending_dot(self):
     '''Test whether a Windows filename ending with a dot is invalid'''
     fs = SystemFS()
     self.assertFalse(fs.validateFilename('test.txt.', platform=PlatformType.WIN))
Beispiel #4
0
 def test_windows_valid(self):
     '''Test whether a complex but valid Windows filename is valid'''
     fs = SystemFS()
     filename = 'This is a valid Wind0ws filename with some characters like ^{[]'
     self.assert_(fs.validateFilename(filename, platform=PlatformType.WIN))
Beispiel #5
0
 def test_windows_invalid_length(self):
     '''Test whether a Windows filename of 256 characters is invalid'''
     fs = SystemFS()
     filename = 'a' * 256
     self.assertFalse(fs.validateFilename(filename, platform=PlatformType.WIN))
Beispiel #6
0
 def test_unix_invalid_length(self):
     '''Test whether a UNIX filename of 256 characters is invalid'''
     fs = SystemFS()
     filename = 'a' * 256
     self.assertFalse(fs.validateFilename(filename, platform=PlatformType.UNIX))
Beispiel #7
0
 def test_unix_invalid_slash(self):
     '''Test whether a UNIX filename containing / is invalid'''
     fs = SystemFS()
     filename = 'foo/bar.txt'
     self.assertFalse(fs.validateFilename(filename, platform=PlatformType.UNIX))
Beispiel #8
0
 def test_unix_invalid_null(self):
     '''Test whether a UNIX filename containing null is invalid'''
     fs = SystemFS()
     filename = 'foo.bar\0.baz'
     self.assertFalse(fs.validateFilename(filename, platform=PlatformType.UNIX))
Beispiel #9
0
 def test_unix_valid(self):
     '''Test whether a complex but valid UNIX filename is valid'''
     fs = SystemFS()
     filename = '.test_kf456\';.,^$&@(@'
     self.assert_(fs.validateFilename(filename, platform=PlatformType.UNIX))
Beispiel #10
0
 def test_generic_invalid_empty(self):
     '''Test whether an empty filename is invalid'''
     fs = SystemFS()
     filename = ''
     self.assertFalse(fs.validateFilename(filename))