def test_other_platform(self): """Test not modifying when it's on other platform.""" self.mock._is_windows.return_value = False # pylint: disable=protected-access path_patcher.patch() self.call(self.path) self.underlying_mock.assert_has_calls([self.expected_call(self.path)])
def setUp(self): helpers.patch(self, [ 'system.path_patcher._is_windows', 'system.path_patcher._short_name_modifier' ]) self.mock._is_windows.return_value = True # pylint: disable=protected-access self.mock._short_name_modifier.side_effect = lambda v: v + '_mod' # pylint: disable=protected-access self.original_file = file path_patcher.patch()
def test_no_short_path(self): """Test modifying.""" self.mock._is_windows.return_value = True # pylint: disable=protected-access path_patcher.patch() self.call(self.path) self.mock.GetShortPathNameW.assert_has_calls( [mock.call(self.prepared_path, None, 0)]) self.underlying_mock.assert_has_calls([self.expected_call(self.path)])
def test_fail(self): """Test failing.""" self.path_lengths = [10, 12] self.mock._is_windows.return_value = True # pylint: disable=protected-access path_patcher.patch() with self.assertRaises(Exception): self.call(self.path) self.mock.GetShortPathNameW.assert_has_calls([ mock.call(self.prepared_path, None, 0), mock.call(self.prepared_path, mock.ANY, 10) ]) self.underlying_mock.assert_has_calls([])
# See the License for the specific language governing permissions and # limitations under the License. """Bot startup script.""" from __future__ import print_function # We want to use utf-8 encoding everywhere throughout the application # instead of the default 'ascii' encoding. This must happen before any # other imports. import sys reload(sys) sys.setdefaultencoding('utf-8') # Before other modules import os, we patch path-related methods, so they are # compatible with windows. from system import path_patcher path_patcher.patch() # Before any other imports, we must fix the path. Some libraries might expect # to be able to import dependencies directly, but we must store these in # subdirectories of common so that they are shared with App Engine. from python.base import modules modules.fix_module_search_paths() from future import standard_library standard_library.install_aliases() from builtins import object import os import time import traceback from base import dates