Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1181)

Side by Side Diff: appengine/swarming/server/bot_code_test.py

Issue 1390773002: Add an assert to ensure UTF-8 locale when handling file paths. (Closed) Base URL: git@github.com:luci/luci-py.git@master
Patch Set: More fixes Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Swarming Authors. All rights reserved. 2 # Copyright 2014 The Swarming Authors. All rights reserved.
3 # Use of this source code is governed by the Apache v2.0 license that can be 3 # Use of this source code is governed by the Apache v2.0 license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import StringIO 6 import StringIO
7 import logging 7 import logging
8 import os 8 import os
9 import re 9 import re
10 import shutil
11 import subprocess 10 import subprocess
12 import sys 11 import sys
13 import tempfile 12 import tempfile
14 import unittest 13 import unittest
15 import zipfile 14 import zipfile
16 15
17 import test_env 16 import test_env
18 test_env.setup_test_env() 17 test_env.setup_test_env()
19 18
20 from components import auth 19 from components import auth
21 from test_support import test_case 20 from test_support import test_case
22 21
23 from server import bot_archive 22 from server import bot_archive
24 from server import bot_code 23 from server import bot_code
25 24
25 CLIENT_DIR = os.path.join(
26 os.path.dirname(os.path.dirname(test_env.APP_DIR)), 'client')
27 sys.path.insert(0, CLIENT_DIR)
28 from third_party.depot_tools import fix_encoding
29 from utils import file_path
30 sys.path.pop(0)
31
26 32
27 class BotManagementTest(test_case.TestCase): 33 class BotManagementTest(test_case.TestCase):
28 def setUp(self): 34 def setUp(self):
29 super(BotManagementTest, self).setUp() 35 super(BotManagementTest, self).setUp()
30 self.testbed.init_user_stub() 36 self.testbed.init_user_stub()
31 37
32 self.mock( 38 self.mock(
33 auth, 'get_current_identity', 39 auth, 'get_current_identity',
34 lambda: auth.Identity(auth.IDENTITY_USER, 'joe@localhost')) 40 lambda: auth.Identity(auth.IDENTITY_USER, 'joe@localhost'))
35 41
(...skipping 30 matching lines...) Expand all
66 with open(bot_path, 'wb') as f: 72 with open(bot_path, 'wb') as f:
67 f.write(zipped_code) 73 f.write(zipped_code)
68 proc = subprocess.Popen( 74 proc = subprocess.Popen(
69 [sys.executable, bot_path, 'start_bot', '-h'], 75 [sys.executable, bot_path, 'start_bot', '-h'],
70 cwd=temp_dir, 76 cwd=temp_dir,
71 stdout=subprocess.PIPE, 77 stdout=subprocess.PIPE,
72 stderr=subprocess.STDOUT) 78 stderr=subprocess.STDOUT)
73 out = proc.communicate()[0] 79 out = proc.communicate()[0]
74 self.assertEqual(0, proc.returncode, out) 80 self.assertEqual(0, proc.returncode, out)
75 finally: 81 finally:
76 shutil.rmtree(temp_dir) 82 file_path.rmtree(temp_dir)
77 83
78 84
79 if __name__ == '__main__': 85 if __name__ == '__main__':
86 fix_encoding.fix_encoding()
80 logging.basicConfig( 87 logging.basicConfig(
81 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) 88 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR)
82 unittest.main() 89 unittest.main()
OLDNEW
« no previous file with comments | « appengine/swarming/remote_smoke_test.py ('k') | appengine/swarming/swarming_bot/bot_code/bot_main_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698