Skip to content

Commit

Permalink
Switching the test runner to py.test
Browse files Browse the repository at this point in the history
This is the first step in moving to py.test.

* Created `scripts/run-tests.py` that handles invoking `py.test` for all samples.
* Updated `tox.ini` to use `scripts/run-tests.py` for the `{py27,py34}{-all}` environments.
* Removed all unneeded `__init__.py` files. The repository is now a loose collection of independent packages instead of being one monster package.

Outstanding questions/issues:
* Currently pytest arguments are specified in `tox.ini`. Not sure if we want to move those into `run-tests.py` or not.
* App Engine is still using `nose` because of `nosegae`. It appears I need to consider creating a `py.test` plugin for app engine.

After this is merged, I can look into converting our tests from `unittest` style to `py.test` style, which is generally cleaner.
  • Loading branch information
Jon Wayne Parrott committed Feb 17, 2016
1 parent b9bb9f7 commit db14c71
Show file tree
Hide file tree
Showing 75 changed files with 209 additions and 167 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ lib
testing/resources/test-env.sh
testing/resources/service-account.json
secrets.tar
.cache
junit.xml
1 change: 1 addition & 0 deletions appengine/bigquery/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

"""
Expand Down
Empty file removed bigquery/__init__.py
Empty file.
Empty file removed bigquery/api/__init__.py
Empty file.
5 changes: 2 additions & 3 deletions bigquery/api/async_query_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
9 changes: 3 additions & 6 deletions bigquery/api/export_data_to_cloud_storage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 2 additions & 3 deletions bigquery/api/getting_started_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 2 additions & 3 deletions bigquery/api/list_datasets_projects_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
7 changes: 3 additions & 4 deletions bigquery/api/load_data_by_post_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 4 additions & 4 deletions bigquery/api/load_data_from_csv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 2 additions & 4 deletions bigquery/api/streaming_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 2 additions & 3 deletions bigquery/api/sync_query_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
Empty file removed blog/__init__.py
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
10 changes: 5 additions & 5 deletions blog/introduction_to_data_models_in_cloud_datastore/wiki_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
Empty file removed cloud_logging/__init__.py
Empty file.
Empty file removed cloud_logging/api/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions cloud_logging/api/list_logs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
import re
import unittest

import list_logs
import testing

from . import list_logs


class TestListLogs(testing.CloudTest):

Expand Down
Empty file removed compute/__init__.py
Empty file.
Empty file removed compute/api/__init__.py
Empty file.
7 changes: 3 additions & 4 deletions compute/api/create_instance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Empty file removed compute/autoscaler/__init__.py
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion compute/autoscaler/demo/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions compute/autoscaler/demo/frontend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion container_engine/django_tutorial/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file removed datastore/__init__.py
Empty file.
Empty file removed datastore/api/__init__.py
Empty file.
5 changes: 2 additions & 3 deletions datastore/api/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions datastore/api/tasks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Empty file removed managed_vms/__init__.py
Empty file.
Empty file removed managed_vms/analytics/__init__.py
Empty file.
Empty file removed managed_vms/cloudsql/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions managed_vms/cloudsql/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
Empty file removed managed_vms/datastore/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions managed_vms/datastore/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
Empty file removed managed_vms/disk/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions managed_vms/disk/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
Empty file.
3 changes: 1 addition & 2 deletions managed_vms/extending_runtime/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@

import os

import main
from nose.plugins.skip import SkipTest
from testing import CloudTest

from . import main


class ExtendingRuntimeTest(CloudTest):

Expand Down
Empty file.
3 changes: 1 addition & 2 deletions managed_vms/hello_world/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
Empty file.
3 changes: 1 addition & 2 deletions managed_vms/hello_world_compat/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
Empty file removed managed_vms/mailgun/__init__.py
Empty file.
Empty file removed managed_vms/memcache/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions managed_vms/memcache/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
Empty file removed managed_vms/pubsub/__init__.py
Empty file.
1 change: 1 addition & 0 deletions managed_vms/pubsub/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions managed_vms/pubsub/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
import json
import os

import main
from testing import CloudTest

from . import main


class PubSubTest(CloudTest):
def setUp(self):
Expand Down
Empty file removed managed_vms/sendgrid/__init__.py
Empty file.
Empty file.
3 changes: 1 addition & 2 deletions managed_vms/static_files/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
Empty file removed managed_vms/storage/__init__.py
Empty file.
Loading

0 comments on commit db14c71

Please sign in to comment.