| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Unit tests for depot_tools.""" | 6 """Unit tests for depot_tools.""" |
| 7 | |
| 8 mox = None | |
| 9 | |
| 10 def OnTestsLoad(): | |
| 11 import os | |
| 12 import sys | |
| 13 old_path = sys.path | |
| 14 global mox | |
| 15 try: | |
| 16 directory, _file = os.path.split(__file__) | |
| 17 sys.path.append(os.path.abspath(os.path.join(directory, 'pymox'))) | |
| 18 sys.path.append(os.path.abspath(os.path.join(directory, '..'))) | |
| 19 try: | |
| 20 import mox as Mox | |
| 21 mox = Mox | |
| 22 except ImportError: | |
| 23 print "Trying to automatically checkout pymox." | |
| 24 import subprocess | |
| 25 subprocess.call(['svn', 'co', 'http://pymox.googlecode.com/svn/trunk', | |
| 26 os.path.join(directory, 'pymox')], | |
| 27 shell=True) | |
| 28 try: | |
| 29 import mox as Mox | |
| 30 mox = Mox | |
| 31 except ImportError: | |
| 32 print >> sys.stderr, ("\nError, failed to load pymox\n") | |
| 33 raise | |
| 34 finally: | |
| 35 # Restore the path | |
| 36 sys.path = old_path | |
| 37 | |
| 38 OnTestsLoad() | |
| OLD | NEW |