コード例 #1
0
 def test__4_1(self):
     ''' Verify normalize() result when input is absolute path '''
     self.assertEqual(utils_path.normalize('/foo/bar/../baz'),
                      ''.join([os.sep, 'foo', os.sep, 'baz']))
     self.assertEqual(utils_path.normalize('/foo/bar/../../baz'),
                      ''.join([os.sep, 'baz']))
     self.assertEqual(utils_path.normalize('/foo/bar/../../../baz'),
                      ''.join([os.sep, 'baz']))
     self.assertEqual(utils_path.normalize('/foo/bar/../../../../baz'),
                      ''.join([os.sep, 'baz']))
コード例 #2
0
 def test__4_1(self):
     ''' Verify normalize() result when input is absolute path '''
     self.assertEqual(utils_path.normalize('/foo/bar/../baz'),
                      ''.join([os.sep, 'foo', os.sep, 'baz']))
     self.assertEqual(utils_path.normalize('/foo/bar/../../baz'),
                      ''.join([os.sep, 'baz']))
     self.assertEqual(utils_path.normalize('/foo/bar/../../../baz'),
                      ''.join([os.sep, 'baz']))
     self.assertEqual(utils_path.normalize('/foo/bar/../../../../baz'),
                      ''.join([os.sep, 'baz']))
コード例 #3
0
    def test__4_2__and__4_3(self):
        ''' Verify normalize() result when input is relative path '''

        # 4.2 the starting node is the parent of foo
        self.assertEqual(utils_path.normalize('foo/bar/../baz'),
                         os.sep.join(['foo', 'baz']))
        self.assertEqual(utils_path.normalize('foo/bar/../../baz'), 'baz')

        # 4.3 the starting node is ABOVE the parent of foo
        self.assertEqual(utils_path.normalize('foo/bar/../../../baz'),
                         os.sep.join(['..', 'baz']))
        self.assertEqual(utils_path.normalize('foo/bar/../../../../baz'),
                         os.sep.join(['..', '..', 'baz']))
コード例 #4
0
    def test__4_2__and__4_3(self):
        ''' Verify normalize() result when input is relative path '''

        # 4.2 the starting node is the parent of foo
        self.assertEqual(utils_path.normalize('foo/bar/../baz'),
                         os.sep.join(['foo', 'baz']))
        self.assertEqual(utils_path.normalize('foo/bar/../../baz'),
                         'baz')

        # 4.3 the starting node is ABOVE the parent of foo
        self.assertEqual(utils_path.normalize('foo/bar/../../../baz'),
                         os.sep.join(['..', 'baz']))
        self.assertEqual(utils_path.normalize('foo/bar/../../../../baz'),
                         os.sep.join(['..', '..', 'baz']))
コード例 #5
0
 def test__3(self):
     ''' Make sure that normalize() converts / to \\ on windows '''
     if os.name == 'nt':
         self.assertEqual(utils_path.normalize('foo/bar'), r'foo\bar')
コード例 #6
0
 def test__2(self):
     ''' Make sure that normalize() simplifies redundant up-level refs '''
     self.assertEqual(utils_path.normalize('/foo/bar/../baz'),
                      os.sep.join(['', 'foo', 'baz']))
コード例 #7
0
 def test__1(self):
     ''' Make sure that normalize() collapses multiple slashes '''
     self.assertEqual(utils_path.normalize('/foo////bar'),
                      os.sep.join(['', 'foo', 'bar']))
コード例 #8
0
 def test__3(self):
     ''' Make sure that normalize() converts / to \\ on windows '''
     if os.name == 'nt':
         self.assertEqual(utils_path.normalize('foo/bar'), r'foo\bar')
コード例 #9
0
 def test__2(self):
     ''' Make sure that normalize() simplifies redundant up-level refs '''
     self.assertEqual(utils_path.normalize('/foo/bar/../baz'),
                      os.sep.join(['', 'foo', 'baz']))
コード例 #10
0
 def test__1(self):
     ''' Make sure that normalize() collapses multiple slashes '''
     self.assertEqual(utils_path.normalize('/foo////bar'),
                      os.sep.join(['', 'foo', 'bar']))