unittests: cut over to the new wrapper
Now that we have a wrapper to deal with the namespace munging, we can
clean up all our unittests. This means:
- add a wrapper symlink for all the unittests
- drop the +x bits on the direct .py file
- drop the shebang on the direct .py file
- delete the manual sys.path munging
- move the mock import to the common system import path
- delete unused os/sys imports
- delete most manual calls to cros_test_lib.main
- add a main() for the few complicated cros_test_lib.main calls
BUG=chromium:219660
TEST=ran all the unittests
Change-Id: I85614c301e48c86a0ca4201c2b60349d2d488e52
Reviewed-on: https://chromium-review.googlesource.com/233832
Reviewed-by: David James <davidjames@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/upload_symbols_unittest.py b/scripts/upload_symbols_unittest.py
old mode 100755
new mode 100644
index 462ab9b..38c8c4f
--- a/scripts/upload_symbols_unittest.py
+++ b/scripts/upload_symbols_unittest.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -11,6 +10,7 @@
import ctypes
import errno
import logging
+import mock
import multiprocessing
import os
import signal
@@ -27,8 +27,6 @@
# on the fly :(.
os.environ.pop('http_proxy', None)
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)),
- '..', '..'))
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
from chromite.lib import osutils
@@ -38,10 +36,7 @@
from chromite.scripts import cros_generate_breakpad_symbols
from chromite.scripts import upload_symbols
-# TODO(build): Finish test wrapper (http://crosbug.com/37517).
-# Until then, this has to be after the chromite imports.
import isolateserver
-import mock
class SymbolServerRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
@@ -527,7 +522,7 @@
self.assertEquals(exp_list, got_list)
-if __name__ == '__main__':
+def main(_argv):
# pylint: disable=W0212
# Set timeouts small so that if the unit test hangs, it won't hang for long.
parallel._BackgroundTask.STARTUP_TIMEOUT = 5
@@ -537,4 +532,4 @@
upload_symbols.INITIAL_RETRY_DELAY = 0
# Run the tests.
- cros_test_lib.main(level=logging.INFO)
+ cros_test_lib.main(level=logging.INFO, module=__name__)