Skip to content

Commit 284f570

Browse files
author
Jon Wayne Parrott
committed
Updating readme with better testing instructions
1 parent 358f8a2 commit 284f570

File tree

1 file changed

+48
-18
lines changed

1 file changed

+48
-18
lines changed

README.md

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,63 @@ For more detailed introduction to a product, check the README in the correspondi
1111

1212
* See [CONTRIBUTING.md](CONTRIBUTING.md)
1313

14-
### How to run the test
14+
## Testing
1515

16-
To run the tests, please install App Engine Python SDK and tox and run
17-
tox with the environment variable PYTHONPATH to the App Engine Python
18-
SDK.
16+
### Local setup
1917

20-
You can install App Engine Python SDK with
21-
[Google Cloud SDK](https://cloud.google.com/sdk/) with the following
22-
command:
18+
Before you can run tests locally you must have:
2319

24-
$ gcloud components update gae-python
20+
* The latest [tox](https://tox.readthedocs.org/en/latest/) and [pip](https://pypi.python.org/pypi/pip) installed.
2521

26-
Here is instructions to run the tests with virtualenv, $GCLOUD is your
27-
Google Cloud SDK installation path.
22+
$ sudo pip install --upgrade tox pip
2823

29-
$ pip install tox
30-
$ export PYTHONPATH=${GCLOUD}/platform/google_appengine
31-
$ export GOOGLE_APPLICATION_CREDENTIALS=your-service-account-json-file
32-
$ export TEST_PROJECT_ID={YOUR_PROJECT_ID}
33-
$ export TEST_BUCKET_NAME={YOUR_BUCKET_NAME}
34-
$ tox
24+
* The [Google Cloud SDK](https://cloud.google.com/sdk/) installed. You can do so with the following command:
25+
26+
$ curl https://sdk.cloud.google.com | bash
27+
28+
* Most tests require you to have an active, billing-enabled project on the [Google Developers Console](https://console.developers.google.com).
29+
* You will need a set of [Service Account Credentials](https://console.developers.google.com/project/_/apiui/credential) for your project in ``json`` form.
30+
* Set the environment variables appropriately for your project.
31+
32+
$ export GOOGLE_APPLICATION_CREDENTIALS=your-service-account-json-file
33+
$ export TEST_PROJECT_ID=your-project-id
34+
$ export TEST_BUCKET_NAME=your-bucket-name
35+
36+
If you want to run the Google App Engine tests, you will need:
37+
38+
* The App Engine Python SDK. You can install this with the Google Cloud SDK:
39+
40+
$ gcloud components update gae-python
41+
42+
* You will need to set an additional environment variable:
43+
44+
$ export GAE_PYTHONPATH=~/google-cloud-sdk/platform/google_appengine
45+
46+
### Test environments
47+
48+
We use [tox](https://tox.readthedocs.org/en/latest/) to configure multiple python environments:
49+
50+
* ``py27`` contains tests for samples that run in a normal Python 2.7 environment. This is (mostly) everything outside of the ``appengine`` directory.
51+
* ``gae`` contains tests for samples that run only in Google App Engine. This is (mostly) everything in the ``appengine`` directory.
52+
* ``pep8`` just runs the linter.
53+
54+
To run tests for a particular environment, invoke tox with the ``-e`` flag:
55+
56+
tox -e py27
57+
58+
To run one particular test suite or provide additional parameters to ``nose``, invoke tox like this:
59+
60+
toxe -e py27 -- storage/tests/test_list_objects.py
61+
62+
*Note*: The ``gae`` environment can't be told to run one particular test at this time.
3563

3664
## Adding new tests
3765

38-
Common testing utilities are located under ``tests``.
66+
There are a handful of common testing utilities are located under ``tests``, see existing tests for example usage.
67+
68+
When adding a new top-level directory, be sure to edit ``.coveragerc`` to include it in coveralls.
3969

40-
When adding a new directory, be sure to edit ``.coveragerc`` to include it in coveralls.
70+
To add new tests that require Google App Engine, please place them in the ``appengine`` directory if possible. If you place them elsewhere, you will need to modify ``tox.ini`` to make the environments appropriately run or ignore your test.
4171

4272
## Licensing
4373

0 commit comments

Comments
 (0)