示例#1
0
 def test_nix_paths(self):
     if platform.system().lower() == "windows":
         self.skipTest(
             "Windows platform found. not running *nix path_join tests")
     for idx, (parts, expected) in enumerate(self.NIX_PATHS):
         path = path_join(*parts)
         self.assertEqual('{0}: {1}'.format(idx, path),
                          '{0}: {1}'.format(idx, expected))
示例#2
0
    def test_windows_paths(self):
        if platform.system().lower() != "windows":
            self.skipTest(
                'Non windows platform found. not running non patched os.path '
                'path_join tests')

        for idx, (parts, expected) in enumerate(self.WIN_PATHS):
            path = path_join(*parts)
            self.assertEqual('{0}: {1}'.format(idx, path),
                             '{0}: {1}'.format(idx, expected))
示例#3
0
 def test_nix_paths(self):
     if platform.system().lower() == "windows":
         self.skipTest(
             "Windows platform found. not running *nix path_join tests"
         )
     for idx, (parts, expected) in enumerate(self.NIX_PATHS):
         path = path_join(*parts)
         self.assertEqual(
             '{0}: {1}'.format(idx, path),
             '{0}: {1}'.format(idx, expected)
         )
示例#4
0
    def test_windows_paths(self):
        if platform.system().lower() != "windows":
            self.skipTest(
                "Non windows platform found. not running non patched os.path path_join tests"
            )

        for idx, (parts, expected) in enumerate(self.WIN_PATHS):
            path = path_join(*parts)
            self.assertEqual(
                '{0}: {1}'.format(idx, path),
                '{0}: {1}'.format(idx, expected)
            )
示例#5
0
    def test_mixed_unicode_and_binary(self):
        '''
        This tests joining paths that contain a mix of components with unicode
        strings and non-unicode strings with the unicode characters as binary.

        This is no longer something we need to concern ourselves with in
        Python 3, but the test should nonetheless pass on Python 3. Really what
        we're testing here is that we don't get a UnicodeDecodeError when
        running on Python 2.
        '''
        a = u'/foo/bar'
        b = 'Д'
        expected = u'/foo/bar/\u0414'
        actual = path_join(a, b)
        self.assertEqual(actual, expected)
示例#6
0
    def test_mixed_unicode_and_binary(self):
        '''
        This tests joining paths that contain a mix of components with unicode
        strings and non-unicode strings with the unicode characters as binary.

        This is no longer something we need to concern ourselves with in
        Python 3, but the test should nonetheless pass on Python 3. Really what
        we're testing here is that we don't get a UnicodeDecodeError when
        running on Python 2.
        '''
        a = u'/foo/bar'
        b = 'Д'
        expected = u'/foo/bar/\u0414'
        actual = path_join(a, b)
        self.assertEqual(actual, expected)
示例#7
0
    def test_windows_paths_patched_path_module(self):
        if platform.system().lower() == "windows":
            self.skipTest(
                "Windows platform found. not running patched os.path path_join tests"
            )

        self.__patch_path()

        for idx, (parts, expected) in enumerate(self.WIN_PATHS):
            path = path_join(*parts)
            self.assertEqual(
                '{0}: {1}'.format(idx, path),
                '{0}: {1}'.format(idx, expected)
            )

        self.__unpatch_path()
示例#8
0
    def test_windows_paths_patched_path_module(self):
        if platform.system().lower() == "windows":
            self.skipTest(
                'Windows platform found. not running patched os.path '
                'path_join tests'
            )

        self.__patch_path()

        for idx, (parts, expected) in enumerate(self.WIN_PATHS):
            path = path_join(*parts)
            self.assertEqual(
                '{0}: {1}'.format(idx, path),
                '{0}: {1}'.format(idx, expected)
            )

        self.__unpatch_path()
示例#9
0
文件: utils_test.py 项目: Roche/salt
 def test_path_join(self, is_windows_mock):
     self.assertFalse(is_windows_mock.return_value)
     expected_path = '/a/b/c/d'
     ret = utils.path_join('/a/b/c', 'd')
     self.assertEqual(ret, expected_path)
示例#10
0
 def test_path_join(self, is_windows_mock):
     self.assertFalse(is_windows_mock.return_value)
     expected_path = '/a/b/c/d'
     ret = utils.path_join('/a/b/c', 'd')
     self.assertEqual(ret, expected_path)
示例#11
0
 def test_path_join(self, is_windows_mock):
     self.assertFalse(is_windows_mock.return_value)
     expected_path = "/a/b/c/d"
     ret = utils.path_join("/a/b/c", "d")
     self.assertEqual(ret, expected_path)
示例#12
0
 def test_path_join(self):
     with patch('salt.utils.is_windows', return_value=False) as is_windows_mock:
         self.assertFalse(is_windows_mock.return_value)
         expected_path = '/a/b/c/d'
         ret = utils.path_join('/a/b/c', 'd')
         self.assertEqual(ret, expected_path)