예제 #1
0
    def test_converter(self):
        converter = dispatch._create_path_to_resource_converter('/a/b')
        # Python built by MSC inserts a drive name like 'C:\' via realpath().
        # Converter Generator expands provided path using realpath() and uses
        # the path including a drive name to verify the prefix.
        os_root = os.path.realpath('/')
        self.assertEqual('/h', converter(os_root + 'a/b/h_wsh.py'))
        self.assertEqual('/c/h', converter(os_root + 'a/b/c/h_wsh.py'))
        self.assertEqual(None, converter(os_root + 'a/b/h.py'))
        self.assertEqual(None, converter('a/b/h_wsh.py'))

        converter = dispatch._create_path_to_resource_converter('a/b')
        self.assertEqual('/h',
                         converter(dispatch._normalize_path('a/b/h_wsh.py')))

        converter = dispatch._create_path_to_resource_converter('/a/b///')
        self.assertEqual('/h', converter(os_root + 'a/b/h_wsh.py'))
        self.assertEqual(
            '/h', converter(dispatch._normalize_path('/a/b/../b/h_wsh.py')))

        converter = dispatch._create_path_to_resource_converter(
            '/a/../a/b/../b/')
        self.assertEqual('/h', converter(os_root + 'a/b/h_wsh.py'))

        converter = dispatch._create_path_to_resource_converter(r'\a\b')
        self.assertEqual('/h', converter(os_root + r'a\b\h_wsh.py'))
        self.assertEqual('/h', converter(os_root + r'a/b/h_wsh.py'))
예제 #2
0
파일: test_dispatch.py 프로젝트: 0X1A/servo
    def test_converter(self):
        converter = dispatch._create_path_to_resource_converter('/a/b')
        # Python built by MSC inserts a drive name like 'C:\' via realpath().
        # Converter Generator expands provided path using realpath() and uses
        # the path including a drive name to verify the prefix.
        os_root = os.path.realpath('/')
        self.assertEqual('/h', converter(os_root + 'a/b/h_wsh.py'))
        self.assertEqual('/c/h', converter(os_root + 'a/b/c/h_wsh.py'))
        self.assertEqual(None, converter(os_root + 'a/b/h.py'))
        self.assertEqual(None, converter('a/b/h_wsh.py'))

        converter = dispatch._create_path_to_resource_converter('a/b')
        self.assertEqual('/h', converter(dispatch._normalize_path(
            'a/b/h_wsh.py')))

        converter = dispatch._create_path_to_resource_converter('/a/b///')
        self.assertEqual('/h', converter(os_root + 'a/b/h_wsh.py'))
        self.assertEqual('/h', converter(dispatch._normalize_path(
            '/a/b/../b/h_wsh.py')))

        converter = dispatch._create_path_to_resource_converter(
            '/a/../a/b/../b/')
        self.assertEqual('/h', converter(os_root + 'a/b/h_wsh.py'))

        converter = dispatch._create_path_to_resource_converter(r'\a\b')
        self.assertEqual('/h', converter(os_root + r'a\b\h_wsh.py'))
        self.assertEqual('/h', converter(os_root + r'a/b/h_wsh.py'))
예제 #3
0
 def test_normalize_path(self):
     self.assertEqual(os.path.abspath('/a/b').replace('\\', '/'),
                      dispatch._normalize_path('/a/b'))
     self.assertEqual(os.path.abspath('/a/b').replace('\\', '/'),
                      dispatch._normalize_path('\\a\\b'))
     self.assertEqual(os.path.abspath('/a/b').replace('\\', '/'),
                      dispatch._normalize_path('/a/c/../b'))
     self.assertEqual(os.path.abspath('abc').replace('\\', '/'),
                      dispatch._normalize_path('abc'))
예제 #4
0
 def test_normalize_path(self):
     self.assertEqual(os.path.abspath('/a/b').replace('\\', '/'),
                      dispatch._normalize_path('/a/b'))
     self.assertEqual(os.path.abspath('/a/b').replace('\\', '/'),
                      dispatch._normalize_path('\\a\\b'))
     self.assertEqual(os.path.abspath('/a/b').replace('\\', '/'),
                      dispatch._normalize_path('/a/c/../b'))
     self.assertEqual(os.path.abspath('abc').replace('\\', '/'),
                      dispatch._normalize_path('abc'))