Skip to content

Commit

Permalink
Add a script to run the tests.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 183998520
  • Loading branch information
tewalds committed Jan 31, 2018
1 parent c8d2b5b commit 63fbc91
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ environment. You can see the list of known maps by running:
$ python -m pysc2.bin.map_list
```

## Run the tests

If you want to submit a pull request, please make sure the tests pass on both
python 2 and 3.

```shell
$ python -m pysc2.bin.run_tests
```

# Environment Details

For a full description of the specifics of how the environment is configured,
Expand Down
11 changes: 11 additions & 0 deletions pysc2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,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.
"""PySC2 module: https://github.com/deepmind/pysc2 ."""

import os


def load_tests(loader, standard_tests, unused_pattern):
"""Our tests end in `_test.py`, so need to override the test discovery."""
this_dir = os.path.dirname(__file__)
package_tests = loader.discover(start_dir=this_dir, pattern="*_test.py")
standard_tests.addTests(package_tests)
return standard_tests
30 changes: 30 additions & 0 deletions pysc2/bin/run_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/python
# Copyright 2017 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.
"""Find and run the tests.
Run as: python -m pysc2.bin.run_tests
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from absl.testing import absltest

import pysc2


if __name__ == '__main__':
absltest.main(module=pysc2)

0 comments on commit 63fbc91

Please sign in to comment.