Browse Source

Create a new testing_support module to move utility modules there

It will simplify importing utility modules from other projects. Otherwise I was getting name conflicts with 'test'.

Reenable W0403 that was disabled in the previous CL.

R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/8508015

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@109636 0039d316-1c4b-4281-b951-d872f2087c98
maruel@chromium.org 13 years ago
parent
commit
0927b7eef8

+ 1 - 1
.gitignore

@@ -6,7 +6,7 @@
 /svn.bat
 /svn_bin
 /svnversion.bat
-/tests/_rietveld
+/depot_tools_testing_lib/_rietveld
 /tests/subversion_config/README.txt
 /tests/subversion_config/auth
 /tests/subversion_config/servers

+ 2 - 2
PRESUBMIT.py

@@ -29,7 +29,7 @@ def CommonChecks(input_api, output_api, tests_to_black_list):
       r'^cpplint_chromium\.py$',
       r'^python_bin[\/\\].+',
       r'^svn_bin[\/\\].+',
-      r'^tests[\/\\]\w+?[\/\\].+']
+      r'^testing_support[\/\\]_rietveld[\/\\].+']
   results.extend(input_api.canned_checks.RunPylint(
       input_api,
       output_api,
@@ -59,7 +59,7 @@ def RunGitClTests(input_api, output_api):
   old_sys_path = sys.path
   try:
     sys.path = [input_api.PresubmitLocalPath()] + sys.path
-    from tests import local_rietveld  # pylint: disable=W0403
+    from testing_support import local_rietveld
     server = local_rietveld.LocalRietveld()
   finally:
     sys.path = old_sys_path

+ 1 - 2
pylintrc

@@ -57,14 +57,13 @@ load-plugins=
 # W0141: Used builtin function ''
 # W0142: Used * or ** magic
 # W0402: Uses of a deprecated module 'string'
-# W0403: Relative import 'X', should be 'Y.X'
 # W0404: 41: Reimport 'XX' (imported line NN)
 # W0511: TODO
 # W0603: Using the global statement
 # W0613: Unused argument ''
 # W0703: Catch "Exception"
 # W1201: Specify string format arguments as logging function parameters
-disable=C0103,C0111,C0302,I0010,I0011,R0401,R0801,R0901,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R0921,R0922,W0122,W0141,W0142,W0402,W0403,W0404,W0511,W0603,W0613,W0703,W1201
+disable=C0103,C0111,C0302,I0010,I0011,R0401,R0801,R0901,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R0921,R0922,W0122,W0141,W0142,W0402,W0404,W0511,W0603,W0613,W0703,W1201
 
 
 [REPORTS]

+ 0 - 0
testing_support/__init__.py


+ 1 - 1
tests/fake_repos.py → testing_support/fake_repos.py

@@ -18,7 +18,7 @@ import tempfile
 import time
 
 # trial_dir must be first for non-system libraries.
-from tests import trial_dir
+from testing_support import trial_dir
 import gclient_utils
 import scm
 import subprocess2

+ 0 - 0
tests/filesystem_mock.py → testing_support/filesystem_mock.py


+ 0 - 1
tests/local_rietveld.py → testing_support/local_rietveld.py

@@ -16,7 +16,6 @@ import socket
 import sys
 import time
 
-sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
 import subprocess2
 
 

+ 0 - 0
tests/patches_data.py → testing_support/patches_data.py


+ 3 - 2
tests/super_mox.py → testing_support/super_mox.py

@@ -90,8 +90,9 @@ class StdoutCheck(object):
   def setUp(self):
     # Override the mock with a StringIO, it's much less painful to test.
     self._old_stdout = sys.stdout
-    sys.stdout = StringIO.StringIO()
-    sys.stdout.flush = lambda: None
+    stdout = StringIO.StringIO()
+    stdout.flush = lambda: None
+    sys.stdout = stdout
 
   def tearDown(self):
     try:

+ 0 - 0
tests/trial_dir.py → testing_support/trial_dir.py


+ 1 - 1
tests/breakpad_unittest.py

@@ -10,7 +10,7 @@ import sys
 
 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
-from super_mox import SuperMoxTestBase
+from testing_support.super_mox import SuperMoxTestBase
 
 import breakpad
 

+ 3 - 2
tests/checkout_test.py

@@ -16,11 +16,12 @@ from xml.etree import ElementTree
 ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
 sys.path.insert(0, os.path.dirname(ROOT_DIR))
 
+from testing_support import fake_repos
+from testing_support.patches_data import GIT, RAW
+
 import checkout
 import patch
 import subprocess2
-from tests import fake_repos
-from tests.patches_data import GIT, RAW
 
 
 # pass -v to enable it.

+ 1 - 1
tests/gcl_unittest.py

@@ -12,7 +12,7 @@ import sys
 
 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
-from super_mox import mox, SuperMoxTestBase
+from testing_support.super_mox import mox, SuperMoxTestBase
 
 import gcl
 import presubmit_support

+ 2 - 2
tests/gclient_scm_test.py

@@ -21,8 +21,8 @@ import __builtin__
 
 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
-from super_mox import mox, StdoutCheck, SuperMoxTestBase
-from super_mox import TestCaseUtils
+from testing_support.super_mox import mox, StdoutCheck, SuperMoxTestBase
+from testing_support.super_mox import TestCaseUtils
 
 import gclient_scm
 import subprocess2

+ 1 - 1
tests/gclient_smoketest.py

@@ -20,7 +20,7 @@ import unittest
 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 sys.path.insert(0, ROOT_DIR)
 
-from fake_repos import join, write, FakeReposTestBase
+from testing_support.fake_repos import join, write, FakeReposTestBase
 
 import subprocess2
 

+ 1 - 1
tests/gclient_test.py

@@ -19,7 +19,7 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
 import gclient
 import gclient_utils
-from tests import trial_dir
+from testing_support import trial_dir
 
 
 def write(filename, content):

+ 2 - 2
tests/gclient_utils_test.py

@@ -9,8 +9,8 @@ import sys
 
 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
-from super_mox import SuperMoxTestBase
-import trial_dir
+from testing_support.super_mox import SuperMoxTestBase
+from testing_support import trial_dir
 
 import gclient_utils
 import subprocess2

+ 2 - 1
tests/owners_unittest.py

@@ -11,8 +11,9 @@ import unittest
 
 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
+from testing_support import filesystem_mock
+
 import owners
-from tests import filesystem_mock
 
 ben = 'ben@example.com'
 brett = 'brett@example.com'

+ 2 - 1
tests/patch_test.py

@@ -13,8 +13,9 @@ import unittest
 
 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
+from testing_support.patches_data import GIT, RAW
+
 import patch
-from tests.patches_data import GIT, RAW
 
 
 class PatchTest(unittest.TestCase):

+ 1 - 1
tests/presubmit_unittest.py

@@ -15,7 +15,7 @@ import time
 
 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
-from super_mox import mox, SuperMoxTestBase
+from testing_support.super_mox import mox, SuperMoxTestBase
 
 import owners
 import presubmit_support as presubmit

+ 2 - 1
tests/rietveld_test.py

@@ -12,9 +12,10 @@ import unittest
 
 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
+from testing_support.patches_data import GIT, RAW
+
 import patch
 import rietveld
-from tests.patches_data import GIT, RAW
 
 
 def _api(files):

+ 2 - 2
tests/scm_unittest.py

@@ -13,9 +13,9 @@ import unittest
 
 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
-from super_mox import SuperMoxTestBase
+from testing_support import fake_repos
+from testing_support.super_mox import SuperMoxTestBase
 
-import fake_repos
 import scm
 import subprocess2
 

+ 1 - 1
tests/trychange_unittest.py

@@ -10,7 +10,7 @@ import sys
 
 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
-from super_mox import SuperMoxTestBase
+from testing_support.super_mox import SuperMoxTestBase
 
 import subprocess2
 import trychange

+ 2 - 1
tests/watchlists_unittest.py

@@ -12,7 +12,8 @@ import sys
 
 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
-import super_mox
+from testing_support import super_mox
+
 import watchlists