From 8c1db226e5351f0725cfa86a2753797f89db2b49 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Thu, 18 Feb 2016 19:52:23 -0800 Subject: [PATCH] Moving all system test scripts in system_tests/. Also removing system_tests/__init__.py so it is no longer a package and making all imports happen locally (rather than from the root of the project). Changes originally inspired by emulator script breakages in #1373. --- MANIFEST.in | 1 - setup.cfg | 2 +- system_tests/__init__.py | 13 ------------- {scripts => system_tests}/attempt_system_tests.py | 6 +++--- system_tests/datastore.py | 6 +++--- system_tests/pubsub.py | 2 +- {scripts => system_tests}/run_emulator.py | 2 +- system_tests/run_system_test.py | 10 +++++----- tox.ini | 11 ++++++----- 9 files changed, 20 insertions(+), 33 deletions(-) delete mode 100644 system_tests/__init__.py rename {scripts => system_tests}/attempt_system_tests.py (97%) rename {scripts => system_tests}/run_emulator.py (98%) diff --git a/MANIFEST.in b/MANIFEST.in index 8ac16676401b..5d1af3e9f0b0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,3 @@ include README.rst graft gcloud global-exclude *.pyc -recursive-exclude system_tests * diff --git a/setup.cfg b/setup.cfg index 556219a2942f..1a5473d09c3d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [nosetests] -ignore-files = run_system_test\.py +exclude-dir = system_tests [bdist_wheel] universal = 1 diff --git a/system_tests/__init__.py b/system_tests/__init__.py deleted file mode 100644 index 61e4b7953cea..000000000000 --- a/system_tests/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2015 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/scripts/attempt_system_tests.py b/system_tests/attempt_system_tests.py similarity index 97% rename from scripts/attempt_system_tests.py rename to system_tests/attempt_system_tests.py index b880755fe6b4..ed503bebab8e 100644 --- a/scripts/attempt_system_tests.py +++ b/system_tests/attempt_system_tests.py @@ -26,6 +26,9 @@ import subprocess import sys +from run_system_test import run_module_tests + + MODULES = ( 'datastore', 'storage', @@ -102,9 +105,6 @@ def prepare_to_run(): def main(): """Run all the system tests if necessary.""" prepare_to_run() - - sys.path.append(ROOT_DIR) - from system_tests.run_system_test import run_module_tests for module in MODULES: run_module_tests(module) diff --git a/system_tests/datastore.py b/system_tests/datastore.py index d995426d9983..dbef49e7d857 100644 --- a/system_tests/datastore.py +++ b/system_tests/datastore.py @@ -27,9 +27,9 @@ from gcloud.exceptions import Conflict # This assumes the command is being run via tox hence the # repository root is the current directory. -from system_tests import clear_datastore -from system_tests import populate_datastore -from system_tests.system_test_utils import EmulatorCreds +import clear_datastore +import populate_datastore +from system_test_utils import EmulatorCreds class Config(object): diff --git a/system_tests/pubsub.py b/system_tests/pubsub.py index 0924c08d381e..b4e73f161779 100644 --- a/system_tests/pubsub.py +++ b/system_tests/pubsub.py @@ -22,7 +22,7 @@ from gcloud.environment_vars import PUBSUB_EMULATOR from gcloud.environment_vars import TESTS_PROJECT from gcloud import pubsub -from system_tests.system_test_utils import EmulatorCreds +from system_test_utils import EmulatorCreds DEFAULT_TOPIC_NAME = 'subscribe-me%d' % (1000 * time.time(),) diff --git a/scripts/run_emulator.py b/system_tests/run_emulator.py similarity index 98% rename from scripts/run_emulator.py rename to system_tests/run_emulator.py index ea86b2c0ec9b..c77f7c277240 100644 --- a/scripts/run_emulator.py +++ b/system_tests/run_emulator.py @@ -28,7 +28,7 @@ from gcloud.environment_vars import GCD_DATASET from gcloud.environment_vars import GCD_HOST from gcloud.environment_vars import PUBSUB_EMULATOR -from system_tests.run_system_test import run_module_tests +from run_system_test import run_module_tests PACKAGE_INFO = { diff --git a/system_tests/run_system_test.py b/system_tests/run_system_test.py index 171a0d1c85f2..9d49c57b0c86 100644 --- a/system_tests/run_system_test.py +++ b/system_tests/run_system_test.py @@ -18,11 +18,11 @@ # This assumes the command is being run via tox hence the # repository root is the current directory. -from system_tests import bigquery -from system_tests import datastore -from system_tests import pubsub -from system_tests import storage -from system_tests import system_test_utils +import bigquery +import datastore +import pubsub +import storage +import system_test_utils REQUIREMENTS = { diff --git a/tox.ini b/tox.ini index 8c8ec161284c..563571df4cbe 100644 --- a/tox.ini +++ b/tox.ini @@ -7,12 +7,13 @@ commands = nosetests deps = nose + nose-exclude unittest2 setenv = PYTHONPATH = {toxinidir}/_testing covercmd = nosetests \ - --ignore-files=run_system_test\.py \ + --exclude-dir=system_tests \ --with-coverage \ --cover-package=gcloud \ --cover-erase \ @@ -84,21 +85,21 @@ passenv = {[testenv:system-tests]passenv} basepython = python2.7 commands = - python {toxinidir}/scripts/attempt_system_tests.py + python {toxinidir}/system_tests/attempt_system_tests.py passenv = GOOGLE_* GCLOUD_* TRAVIS* encrypted_* [testenv:system-tests3] basepython = python3.4 commands = - python {toxinidir}/scripts/attempt_system_tests.py + python {toxinidir}/system_tests/attempt_system_tests.py passenv = {[testenv:system-tests]passenv} [testenv:datastore-emulator] basepython = python2.7 commands = - python {toxinidir}/scripts/run_emulator.py --package=datastore + python {toxinidir}/system_tests/run_emulator.py --package=datastore setenv = PYTHONPATH = {toxinidir}/_testing GCLOUD_NO_PRINT=true @@ -110,6 +111,6 @@ deps = basepython = python2.7 commands = - python {toxinidir}/scripts/run_emulator.py --package=pubsub + python {toxinidir}/system_tests/run_emulator.py --package=pubsub passenv = GCLOUD_* deps = {[testenv:datastore-emulator]deps}