示例#1
0
    def test_format_file_path_handles_exceptions(self):
        path = 'c:\\some\\path////to\\\\\\a\\file.txt'
        expected = path

        with mock.patch('os.path.abspath') as mock_abspath:
            mock_abspath.side_effect = Exception('foobar')

            result = format_file_path(path)
            self.assertPathsEqual(expected, result)
示例#2
0
    def test_format_file_path_handles_exceptions(self):
        path = 'c:\\some\\path////to\\\\\\a\\file.txt'
        expected = path

        with mock.patch('os.path.abspath') as mock_abspath:
            mock_abspath.side_effect = Exception('foobar')

            result = format_file_path(path)
            self.assertEquals(expected, result)
示例#3
0
    def test_format_file_path_uppercase_windows_drive(self):
        path = 'c:\\some\\path////to\\\\\\a\\file.txt'
        expected = 'C:/some/path/to/a/file.txt'

        with mock.patch('os.path.realpath') as mock_realpath:
            mock_realpath.return_value = path
            with mock.patch('os.path.abspath') as mock_abspath:
                mock_abspath.return_value = path

                result = format_file_path(path)
                self.assertEquals(expected, result)
示例#4
0
    def test_format_file_path_windows_network_mount(self):
        path = '\\\\some\\path////to\\\\\\a\\file.txt'
        expected = '//some/path/to/a/file.txt'

        with mock.patch('os.path.realpath') as mock_realpath:
            mock_realpath.return_value = path
            with mock.patch('os.path.abspath') as mock_abspath:
                mock_abspath.return_value = path

                result = format_file_path(path)
                self.assertPathsEqual(expected, result)
示例#5
0
    def test_format_file_path_uppercase_windows_drive(self):
        path = 'c:\\some\\path////to\\\\\\a\\file.txt'
        expected = 'C:/some/path/to/a/file.txt'

        with mock.patch('os.path.realpath') as mock_realpath:
            mock_realpath.return_value = path
            with mock.patch('os.path.abspath') as mock_abspath:
                mock_abspath.return_value = path

                result = format_file_path(path)
                self.assertPathsEqual(expected, result)
示例#6
0
    def test_format_file_path_windows_network_mount(self):
        path = '\\\\some\\path////to\\\\\\a\\file.txt'
        expected = '//some/path/to/a/file.txt'

        with mock.patch('os.path.realpath') as mock_realpath:
            mock_realpath.return_value = path
            with mock.patch('os.path.abspath') as mock_abspath:
                mock_abspath.return_value = path

                result = format_file_path(path)
                self.assertPathsEqual(expected, result)
示例#7
0
 def test_format_file_path_forces_forward_slashes(self):
     path = 'some\\path////to\\\\\\a\\file.txt'
     expected = os.path.realpath('some/path/to/a/file.txt')
     result = format_file_path(path)
     self.assertEquals(expected, result)
示例#8
0
 def test_format_file_path_forces_forward_slashes(self):
     path = 'some\\path////to\\\\\\a\\file.txt'
     expected = os.path.realpath('some/path/to/a/file.txt')
     result = format_file_path(path)
     self.assertPathsEqual(expected, result)