diff --git a/.gitignore b/.gitignore index 146119deb5f9..cbe7b6c36208 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ lib testing/resources/test-env.sh testing/resources/service-account.json secrets.tar +.cache +junit.xml diff --git a/appengine/bigquery/main.py b/appengine/bigquery/main.py index fe825622d6bc..1c035272ce7a 100644 --- a/appengine/bigquery/main.py +++ b/appengine/bigquery/main.py @@ -11,6 +11,7 @@ # 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. + # [START all] """ diff --git a/bigquery/__init__.py b/bigquery/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/bigquery/api/__init__.py b/bigquery/api/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/bigquery/api/async_query_test.py b/bigquery/api/async_query_test.py index 575d90326df3..005b1b0d7f4f 100644 --- a/bigquery/api/async_query_test.py +++ b/bigquery/api/async_query_test.py @@ -10,13 +10,12 @@ # 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. -# + import json +from async_query import main import testing -from .async_query import main - class TestAsyncQuery(testing.CloudTest): diff --git a/bigquery/api/export_data_to_cloud_storage_test.py b/bigquery/api/export_data_to_cloud_storage_test.py index 135b2bf075d5..77820bb2792c 100644 --- a/bigquery/api/export_data_to_cloud_storage_test.py +++ b/bigquery/api/export_data_to_cloud_storage_test.py @@ -10,16 +10,13 @@ # 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. -# -"""Tests for export_table_to_gcs.""" -from nose.plugins.attrib import attr +from export_data_to_cloud_storage import main +import pytest from testing import CloudTest -from .export_data_to_cloud_storage import main - -@attr('slow') +@pytest.mark.slow class TestExportTableToGCS(CloudTest): dataset_id = 'test_dataset' table_id = 'test_table' diff --git a/bigquery/api/getting_started_test.py b/bigquery/api/getting_started_test.py index 4d32f4d44cbc..74114db8f5e8 100644 --- a/bigquery/api/getting_started_test.py +++ b/bigquery/api/getting_started_test.py @@ -10,13 +10,12 @@ # 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. -# + import re +from getting_started import main import testing -from .getting_started import main - class TestGettingStarted(testing.CloudTest): def test_main(self): diff --git a/bigquery/api/list_datasets_projects_test.py b/bigquery/api/list_datasets_projects_test.py index 2dd92a8d6b9b..09d4ad52d51a 100644 --- a/bigquery/api/list_datasets_projects_test.py +++ b/bigquery/api/list_datasets_projects_test.py @@ -10,13 +10,12 @@ # 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. -# + import re +from list_datasets_projects import main import testing -from .list_datasets_projects import main - class TestListDatasetsProjects(testing.CloudTest): diff --git a/bigquery/api/load_data_by_post_test.py b/bigquery/api/load_data_by_post_test.py index 08286e144b1e..d88c7fcf0e7a 100644 --- a/bigquery/api/load_data_by_post_test.py +++ b/bigquery/api/load_data_by_post_test.py @@ -13,13 +13,12 @@ import re -from nose.plugins.attrib import attr +from load_data_by_post import load_data +import pytest import testing -from .load_data_by_post import load_data - -@attr('slow') +@pytest.mark.slow class TestLoadDataByPost(testing.CloudTest): dataset_id = 'ephemeral_test_dataset' table_id = 'load_data_by_post' diff --git a/bigquery/api/load_data_from_csv_test.py b/bigquery/api/load_data_from_csv_test.py index fd64fdeca9a2..3bb989a6fceb 100644 --- a/bigquery/api/load_data_from_csv_test.py +++ b/bigquery/api/load_data_from_csv_test.py @@ -11,13 +11,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from nose.plugins.attrib import attr -from testing import CloudTest -from .load_data_from_csv import main +from load_data_from_csv import main +import pytest +from testing import CloudTest -@attr('slow') +@pytest.mark.slow class TestLoadDataFromCSV(CloudTest): dataset_id = 'test_dataset' table_id = 'test_import_table' diff --git a/bigquery/api/streaming_test.py b/bigquery/api/streaming_test.py index 29160231e2fe..44751e47727d 100644 --- a/bigquery/api/streaming_test.py +++ b/bigquery/api/streaming_test.py @@ -10,14 +10,12 @@ # 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. -# -"""Tests for export_table_to_gcs.""" + import json +import streaming from testing import capture_stdout, CloudTest -from . import streaming - class TestStreaming(CloudTest): dataset_id = 'test_dataset' diff --git a/bigquery/api/sync_query_test.py b/bigquery/api/sync_query_test.py index 975095990424..c39f6af0abc4 100644 --- a/bigquery/api/sync_query_test.py +++ b/bigquery/api/sync_query_test.py @@ -10,13 +10,12 @@ # 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. -# + import json +from sync_query import main from testing import capture_stdout, CloudTest -from .sync_query import main - class TestSyncQuery(CloudTest): diff --git a/blog/__init__.py b/blog/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/blog/introduction_to_data_models_in_cloud_datastore/__init__.py b/blog/introduction_to_data_models_in_cloud_datastore/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/blog/introduction_to_data_models_in_cloud_datastore/blog_test.py b/blog/introduction_to_data_models_in_cloud_datastore/blog_test.py index 3475b212b440..6da23560cf07 100644 --- a/blog/introduction_to_data_models_in_cloud_datastore/blog_test.py +++ b/blog/introduction_to_data_models_in_cloud_datastore/blog_test.py @@ -10,14 +10,13 @@ # 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. -# -from nose.plugins.attrib import attr -from testing import CloudTest -from .blog import main +from blog import main +import pytest +from testing import CloudTest -@attr('slow') +@pytest.mark.slow class BlogTestCase(CloudTest): """Simple test case that ensures the blog code doesn't throw any errors.""" diff --git a/blog/introduction_to_data_models_in_cloud_datastore/wiki_test.py b/blog/introduction_to_data_models_in_cloud_datastore/wiki_test.py index 17cfe5396120..4ad37a2ba269 100644 --- a/blog/introduction_to_data_models_in_cloud_datastore/wiki_test.py +++ b/blog/introduction_to_data_models_in_cloud_datastore/wiki_test.py @@ -10,14 +10,14 @@ # 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. -# -from nose.plugins.attrib import attr -from testing import CloudTest -from .wiki import main + +import pytest +from testing import CloudTest +from wiki import main -@attr('slow') +@pytest.mark.slow class WikiTestCase(CloudTest): """Simple test case that ensures the wiki code doesn't throw any errors.""" diff --git a/cloud_logging/__init__.py b/cloud_logging/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/cloud_logging/api/__init__.py b/cloud_logging/api/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/cloud_logging/api/list_logs_test.py b/cloud_logging/api/list_logs_test.py index 0f5d7d598b07..fc7feb727835 100644 --- a/cloud_logging/api/list_logs_test.py +++ b/cloud_logging/api/list_logs_test.py @@ -14,10 +14,9 @@ import re import unittest +import list_logs import testing -from . import list_logs - class TestListLogs(testing.CloudTest): diff --git a/compute/__init__.py b/compute/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/compute/api/__init__.py b/compute/api/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/compute/api/create_instance_test.py b/compute/api/create_instance_test.py index 9bf852d78870..beb7c93f85b4 100644 --- a/compute/api/create_instance_test.py +++ b/compute/api/create_instance_test.py @@ -13,13 +13,12 @@ import re -from nose.plugins.attrib import attr +from create_instance import main +import pytest import testing -from .create_instance import main - -@attr('slow') +@pytest.mark.slow class TestComputeGettingStarted(testing.CloudTest): def test_main(self): diff --git a/compute/autoscaler/__init__.py b/compute/autoscaler/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/compute/autoscaler/demo/__init__.py b/compute/autoscaler/demo/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/compute/autoscaler/demo/frontend.py b/compute/autoscaler/demo/frontend.py index e464e9af7856..c0d1ae600301 100644 --- a/compute/autoscaler/demo/frontend.py +++ b/compute/autoscaler/demo/frontend.py @@ -10,7 +10,7 @@ # 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. -# + """A simple web server which responds to HTTP GET requests by consuming CPU. This binary runs in a GCE VM. It serves HTTP requests on port 80. Every request with path '/service' consumes 1 core-second of CPU time, with the timeout of diff --git a/compute/autoscaler/demo/frontend_test.py b/compute/autoscaler/demo/frontend_test.py index 6ef175faea08..dc9deb3bad4a 100644 --- a/compute/autoscaler/demo/frontend_test.py +++ b/compute/autoscaler/demo/frontend_test.py @@ -11,11 +11,10 @@ # 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. -# import unittest -from . import frontend +import frontend class FakeTime(object): diff --git a/container_engine/django_tutorial/Dockerfile b/container_engine/django_tutorial/Dockerfile index 5d223d0bac17..220f232cb718 100644 --- a/container_engine/django_tutorial/Dockerfile +++ b/container_engine/django_tutorial/Dockerfile @@ -10,7 +10,7 @@ # 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. -# + # [START docker] # The Google App Engine python runtime is Debian Jessie with Python installed diff --git a/datastore/__init__.py b/datastore/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/datastore/api/__init__.py b/datastore/api/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/datastore/api/snippets_test.py b/datastore/api/snippets_test.py index 24b45e3575d9..973c18fb1a2d 100644 --- a/datastore/api/snippets_test.py +++ b/datastore/api/snippets_test.py @@ -10,15 +10,14 @@ # 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. -# + from functools import wraps import time from gcloud import datastore +import snippets from testing import CloudTest, mark_flaky -from . import snippets - def eventually_consistent(f): @wraps(f) diff --git a/datastore/api/tasks_test.py b/datastore/api/tasks_test.py index 58452f899b17..528a40702e50 100644 --- a/datastore/api/tasks_test.py +++ b/datastore/api/tasks_test.py @@ -12,10 +12,9 @@ # limitations under the License. from gcloud import datastore +import tasks from testing import CloudTest, mark_flaky -from . import tasks - @mark_flaky class DatastoreTasksTest(CloudTest): diff --git a/managed_vms/__init__.py b/managed_vms/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/analytics/__init__.py b/managed_vms/analytics/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/cloudsql/__init__.py b/managed_vms/cloudsql/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/cloudsql/main_test.py b/managed_vms/cloudsql/main_test.py index 66d7eb3f9601..ba275e4c4906 100644 --- a/managed_vms/cloudsql/main_test.py +++ b/managed_vms/cloudsql/main_test.py @@ -12,10 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import main from testing import CloudTest -from . import main - class CloudSqlTest(CloudTest): diff --git a/managed_vms/datastore/__init__.py b/managed_vms/datastore/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/datastore/main_test.py b/managed_vms/datastore/main_test.py index e883e7251d68..3e8831cb483a 100644 --- a/managed_vms/datastore/main_test.py +++ b/managed_vms/datastore/main_test.py @@ -12,10 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import main from testing import CloudTest -from . import main - class DatastoreTest(CloudTest): diff --git a/managed_vms/disk/__init__.py b/managed_vms/disk/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/disk/main_test.py b/managed_vms/disk/main_test.py index 15aa04917887..d341fe5e8352 100644 --- a/managed_vms/disk/main_test.py +++ b/managed_vms/disk/main_test.py @@ -12,10 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import main from testing import CloudTest -from . import main - class DiskTest(CloudTest): diff --git a/managed_vms/extending_runtime/__init__.py b/managed_vms/extending_runtime/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/extending_runtime/main_test.py b/managed_vms/extending_runtime/main_test.py index 583ebbad0a8d..716e139b39e0 100644 --- a/managed_vms/extending_runtime/main_test.py +++ b/managed_vms/extending_runtime/main_test.py @@ -14,11 +14,10 @@ import os +import main from nose.plugins.skip import SkipTest from testing import CloudTest -from . import main - class ExtendingRuntimeTest(CloudTest): diff --git a/managed_vms/hello_world/__init__.py b/managed_vms/hello_world/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/hello_world/main_test.py b/managed_vms/hello_world/main_test.py index 34a3ab507b9d..f28b07ad42f7 100644 --- a/managed_vms/hello_world/main_test.py +++ b/managed_vms/hello_world/main_test.py @@ -12,10 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import main from testing import CloudTest -from . import main - class HelloWorldTest(CloudTest): diff --git a/managed_vms/hello_world_compat/__init__.py b/managed_vms/hello_world_compat/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/hello_world_compat/main_test.py b/managed_vms/hello_world_compat/main_test.py index 34a3ab507b9d..f28b07ad42f7 100644 --- a/managed_vms/hello_world_compat/main_test.py +++ b/managed_vms/hello_world_compat/main_test.py @@ -12,10 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import main from testing import CloudTest -from . import main - class HelloWorldTest(CloudTest): diff --git a/managed_vms/mailgun/__init__.py b/managed_vms/mailgun/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/memcache/__init__.py b/managed_vms/memcache/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/memcache/main_test.py b/managed_vms/memcache/main_test.py index 5cc4fb852c51..4445f4be047a 100644 --- a/managed_vms/memcache/main_test.py +++ b/managed_vms/memcache/main_test.py @@ -12,10 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import main from testing import CloudTest -from . import main - class MemcacheTest(CloudTest): diff --git a/managed_vms/pubsub/__init__.py b/managed_vms/pubsub/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/pubsub/main.py b/managed_vms/pubsub/main.py index 0daf8bb5ad13..f9b3893fb4a3 100644 --- a/managed_vms/pubsub/main.py +++ b/managed_vms/pubsub/main.py @@ -11,6 +11,7 @@ # 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. + # [START app] import base64 import json diff --git a/managed_vms/pubsub/main_test.py b/managed_vms/pubsub/main_test.py index b34662134549..84430e8c0906 100644 --- a/managed_vms/pubsub/main_test.py +++ b/managed_vms/pubsub/main_test.py @@ -16,10 +16,9 @@ import json import os +import main from testing import CloudTest -from . import main - class PubSubTest(CloudTest): def setUp(self): diff --git a/managed_vms/sendgrid/__init__.py b/managed_vms/sendgrid/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/static_files/__init__.py b/managed_vms/static_files/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/static_files/main_test.py b/managed_vms/static_files/main_test.py index 9861d6e953ea..d230546e2fdf 100644 --- a/managed_vms/static_files/main_test.py +++ b/managed_vms/static_files/main_test.py @@ -12,10 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import main from testing import CloudTest -from . import main - class StaticFilesTest(CloudTest): diff --git a/managed_vms/storage/__init__.py b/managed_vms/storage/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/storage/main_test.py b/managed_vms/storage/main_test.py index 3037ffdf63d1..50e6d702b439 100644 --- a/managed_vms/storage/main_test.py +++ b/managed_vms/storage/main_test.py @@ -12,12 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +import main import requests from six import BytesIO from testing import CloudTest -from . import main - class StorageTest(CloudTest): def setUp(self): diff --git a/managed_vms/twilio/__init__.py b/managed_vms/twilio/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/managed_vms/websockets/__init__.py b/managed_vms/websockets/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/monitoring/__init__.py b/monitoring/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/monitoring/api/__init__.py b/monitoring/api/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/monitoring/api/auth_test.py b/monitoring/api/auth_test.py index 5bd05c0f4a0f..49725a5f2b1a 100644 --- a/monitoring/api/auth_test.py +++ b/monitoring/api/auth_test.py @@ -13,10 +13,9 @@ import re +import auth import testing -from . import auth - class TestTimeseriesList(testing.CloudTest): diff --git a/requirements-py27-dev.txt b/requirements-py27-dev.txt index 66a2b53c0620..54d182028dc0 100644 --- a/requirements-py27-dev.txt +++ b/requirements-py27-dev.txt @@ -26,3 +26,5 @@ twilio==6.3.dev0 sendgrid==1.6.22 Flask-Sockets==0.2.0 mysql-python==1.2.5 +pytest +pytest-cov diff --git a/requirements-py34-dev.txt b/requirements-py34-dev.txt index e9b43e36f825..3bea20011245 100644 --- a/requirements-py34-dev.txt +++ b/requirements-py34-dev.txt @@ -24,3 +24,5 @@ flaky==3.1.0 Django==1.9.2 twilio==6.3.dev0 sendgrid==1.6.22 +pytest +pytest-cov diff --git a/scripts/run-tests.py b/scripts/run-tests.py new file mode 100755 index 000000000000..0dece74e86dd --- /dev/null +++ b/scripts/run-tests.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python + +# Copyright (C) 2013 Google Inc. +# +# 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. + +import argparse +import subprocess +import sys + +import pytest # flake8: noqa +import _pytest.main + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--junit', help='Output junit test report.') + parser.add_argument('--run-slow', help='Run slow tests.') + parser.add_argument( + 'directories', nargs='+', help='Directories to run py.test on.') + args = parser.parse_args() + + extra_args = [] + + if not args.run_slow: + extra_args.append('-m not slow and not flaky') + + for directory in args.directories: + per_directory_args = [] + + if args.junit: + per_directory_args.append( + '--junitxml={}/junit.xml'.format(directory)) + + # We could use pytest.main, however, we need import isolatation between + # test runs. Without using subprocess, any test files that are named + # the same will cause pytest to fail. Rather than do sys.module magic + # between runs, it's cleaner to just do a subprocess. + code = subprocess.call( + ['py.test'] + extra_args + per_directory_args + [directory]) + + if code not in ( + _pytest.main.EXIT_OK, _pytest.main.EXIT_NOTESTSCOLLECTED): + sys.exit(code) + +if __name__ == '__main__': + main() diff --git a/storage/__init__.py b/storage/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/storage/api/__init__.py b/storage/api/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/storage/api/compose_objects_test.py b/storage/api/compose_objects_test.py index 5497d2cec12b..071edadc2f98 100644 --- a/storage/api/compose_objects_test.py +++ b/storage/api/compose_objects_test.py @@ -11,10 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +from compose_objects import main from testing import CloudTest -from .compose_objects import main - class TestComposeObjects(CloudTest): def test_main(self): diff --git a/storage/api/list_objects.py b/storage/api/list_objects.py index 705aab8c6371..965ef91f9740 100644 --- a/storage/api/list_objects.py +++ b/storage/api/list_objects.py @@ -13,6 +13,7 @@ # 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. + # [START all] """Command-line sample application for listing all objects in a bucket using diff --git a/storage/api/list_objects_test.py b/storage/api/list_objects_test.py index ecb9785faf5b..4cdee901937c 100644 --- a/storage/api/list_objects_test.py +++ b/storage/api/list_objects_test.py @@ -10,10 +10,9 @@ # 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. -# -from testing import CloudTest -from .list_objects import main +from list_objects import main +from testing import CloudTest class TestListObjects(CloudTest): diff --git a/storage/transfer_service/__init__.py b/storage/transfer_service/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/testing/__init__.py b/testing/__init__.py index 970b3ce1d730..b3373d37cd15 100644 --- a/testing/__init__.py +++ b/testing/__init__.py @@ -10,7 +10,6 @@ # 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. -# from .appengine import AppEngineTest from .cloud import CloudTest diff --git a/testing/appengine.py b/testing/appengine.py index 3db88e643e21..be24512a6fb8 100644 --- a/testing/appengine.py +++ b/testing/appengine.py @@ -10,7 +10,6 @@ # 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. -# """ Common testing tools for Google App Engine tests. diff --git a/testing/cloud.py b/testing/cloud.py index 0411f26504f6..736ee63598f5 100644 --- a/testing/cloud.py +++ b/testing/cloud.py @@ -10,7 +10,6 @@ # 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. -# """ Common testing tools for cloud samples. diff --git a/testing/flaky.py b/testing/flaky.py index fc85431ab1f1..260b2dd973b6 100644 --- a/testing/flaky.py +++ b/testing/flaky.py @@ -10,7 +10,6 @@ # 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. -# """ Tools for dealing with flaky tests. diff --git a/tox.ini b/tox.ini index bc7a3e9b045c..cfc741c34eb9 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] skipsdist = True -envlist = pep8, reqcheck, gae, py27, py34 +envlist = pep8, py27, py34, gae [testenv] passenv = @@ -19,111 +19,120 @@ passenv = basepython = python2.7 deps = -rrequirements.txt -commonargs = - --with-timer - --with-coverage - --cover-tests - --cover-branches - --cover-inclusive - --with-flaky - --no-success-flaky-report - --exclude-dir=managed_vms/django_cloudsql - --exclude-dir=managed_vms/hello_world_django - -[testenv:reqcheck] -commands = - bash -c "find . -name requirements\*.txt |\ - xargs -P 4 -n 1 gcp-python-repo-tools check-requirements" -whitelist_externals = - bash - find - xargs - gcp-python-repo-tools - -[testenv:requpdate] -commands = - bash -c "find . -name requirements\*.txt |\ - xargs -P 4 -n 1 gcp-python-repo-tools update-requirements" -whitelist_externals = - bash - find - xargs - gcp-python-repo-tools +examples = + bigquery/api + blog/introduction_to_data_models_in_cloud_datastore + cloud_logging/api + compute/api + compute/autoscaler + datastore/api + managed_vms/cloudsql + managed_vms/datastore + managed_vms/disk + managed_vms/extending_runtime + managed_vms/hello_world + managed_vms/hello_world_compat + managed_vms/memcache + managed_vms/pubsub + managed_vms/static_files + managed_vms/storage + monitoring/api + storage/api +setenv = + PYTHONPATH=. -[testenv:gae] -deps = - {[testenv]deps} - -rrequirements-py27-dev.txt +[testenv:pep8] +deps = + flake8 + flake8-import-order commands = - # Create a lib directory, otherwise, the vendor library will explode. - mkdir lib - nosetests --with-gae \ - --gae-app=appengine/resources/app.yaml \ - --logging-level=INFO \ - --with-xunit \ - --xunit-testsuite-name gae \ - --xunit-file nosetests-gae.xml \ - {[testenv]commonargs} \ - {posargs:appengine} -setenv = - PYTHONPATH={env:GAE_PYTHONPATH:} -whitelist_externals = mkdir + flake8 --builtin=gettext --max-complexity=10 --import-order-style=google {posargs} [testenv:py27] deps = {[testenv]deps} -rrequirements-py27-dev.txt commands = - nosetests \ - --exclude-dir=appengine \ - {[testenv]commonargs} \ - {posargs:-a '!slow,!flaky'} + python scripts/run-tests.py {posargs:{[testenv]examples}} + coverage report [testenv:py34] basepython = python3.4 deps = {[testenv]deps} -rrequirements-py34-dev.txt -commands = - nosetests \ - --exclude-dir=appengine \ - # Websockets doesn't work with py34 because of gevent dep. - --exclude-dir=managed_vms/websockets \ - {[testenv]commonargs} \ - {posargs:-a '!slow,!flaky'} +commands = + python scripts/run-tests.py {posargs:{[testenv]examples}} + coverage report [testenv:py27-all] deps = {[testenv:py27]deps} -commands = - nosetests \ - --exclude-dir=appengine \ - {[testenv]commonargs} \ - --with-xunit \ - --xunit-testsuite-name py27 \ - --xunit-file nosetests-py27.xml \ - {posargs} +commands = + python scripts/run-tests.py \ + --junit \ + --run-slow \ + {posargs:{[testenv]examples}} + coverage report [testenv:py34-all] basepython = python3.4 deps = {[testenv:py34]deps} -commands = - nosetests \ - --exclude-dir=appengine \ - --exclude-dir=managed_vms/websockets \ - {[testenv]commonargs} \ - --with-xunit \ - --xunit-testsuite-name py34 \ - --xunit-file nosetests-py34.xml \ - {posargs} +commands = + python scripts/run-tests.py \ + --junit \ + --run-slow \ + {posargs:{[testenv]examples}} + coverage report -[testenv:pep8] -deps = - flake8 - flake8-import-order +[testenv:gae] +deps = + {[testenv]deps} + -rrequirements-py27-dev.txt commands = - flake8 --builtin=gettext --max-complexity=10 --import-order-style=google {posargs} + # Create a lib directory, otherwise, the vendor library will explode. + mkdir lib + nosetests --with-gae \ + --gae-app=appengine/resources/app.yaml \ + --logging-level=INFO \ + --with-xunit \ + --xunit-testsuite-name gae \ + --xunit-file appengine/junit.xml \ + --with-timer \ + --with-coverage \ + --cover-tests \ + --cover-branches \ + --cover-inclusive \ + --with-flaky \ + --no-success-flaky-report \ + {posargs:appengine} +setenv = + PYTHONPATH={env:GAE_PYTHONPATH:} +whitelist_externals = mkdir [flake8] exclude=container_engine/django_tutorial/polls/migrations/* + +[pytest] +addopts = -x --no-flaky-report --no-success-flaky-report --cov --cov-config .coveragerc --cov-append --cov-report= + +[testenv:reqcheck] +commands = + bash -c "find . -name requirements\*.txt |\ + xargs -P 4 -n 1 gcp-python-repo-tools check-requirements" +whitelist_externals = + bash + find + xargs + gcp-python-repo-tools + +[testenv:requpdate] +commands = + bash -c "find . -name requirements\*.txt |\ + xargs -P 4 -n 1 gcp-python-repo-tools update-requirements" +whitelist_externals = + bash + find + xargs + gcp-python-repo-tools