Skip to content

Commit

Permalink
Update configs and instructions for running tests manually. (python#1137
Browse files Browse the repository at this point in the history
)

- Switch requirements-tests-py3.txt to use mypy GitHub master.
- Exclude .venv{2,3} (suggested in README.md) in .flake8 and .gitignore.
- Update instructions in README.md to be working.
- Remove runtests.sh script and mentions of it -- I can't get it to work
  and the three steps are easily run by hand.
  • Loading branch information
gvanrossum authored and JelleZijlstra committed Apr 9, 2017
1 parent f741429 commit 761ee6a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 34 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ ignore = F401, F811, E127, E128, E301, E302, E305, E501, E701, E704, B303
# A nice future improvement would be to provide separate .flake8
# configurations for Python 2 and Python 3 files.
builtins = StandardError,apply,basestring,buffer,cmp,coerce,execfile,file,intern,long,raw_input,reduce,reload,unichr,unicode,xrange
exclude = .venv*,@*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ analyze.py
.*.sw?
.vscode/
.idea/
.venv*/
38 changes: 11 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,30 +79,33 @@ The tests are automatically run by Travis CI on every PR and push to
the repo. There are two separate sets of tests: `tests/mypy_test.py`
runs tests against [mypy](https://github.com/python/mypy/), while
`tests/pytype_tests.py` runs tests against
[pytype](https://github.com/google/pytype/). The script runtests.sh
runs both sets of tests and flake8 over all .pyi files.
[pytype](https://github.com/google/pytype/).

Both sets of tests are shallow -- they verify that all stubs can be
imported but they don't check whether stubs match their implementation
(in the Python standard library or a third-party package). Also note
that each set of tests has a blacklist of modules that are not tested
at all. The blacklists also live in the tests directory.

To manually run the mypy tests, you need to have Python 3.5 or higher.
To manually run the mypy tests, you need to have Python 3.5 or higher;
Python 3.6.1 or higher is recommended.
Run:
```
$ python3.5 -m venv .venv3
$ python3.6 -m venv .venv3
$ source .venv3/bin/activate
(.venv3)$ pip install -r requirements-tests-py3.txt
(.venv3)$ pip3 install -r requirements-tests-py3.txt
```
This will install mypy-lang, typed-ast, and flake8. You can then run
mypy tests and flake8 tests by invoking:
This will install mypy (you need the latest master branch from GitHub),
typed-ast, and flake8. You can then run mypy tests and flake8 tests by
invoking:
```
(.venv3)$ python tests/mypy_test.py
(.venv3)$ python3 tests/mypy_test.py
...
(.venv3)$ flake8
...
```
(Note that flake8 only works with Python 3.6 or higher.)

To run the pytype tests, you need a separate virtual environment with
Python 2.7. Run:
```
Expand All @@ -116,25 +119,6 @@ tests by running:
(.venv2)$ python tests/pytype_test.py
```

To be able to everything with ``runtests.sh``, copy the ``pytype`` script
from the Python 2 virtualenv to the Python 3 one:
```
$ cp .venv2/bin/pytype .venv3/bin/pytype
$ source .venv3/bin/activate
(.venv3)$ ./runtests.sh
running mypy --python-version 3.6 --strict-optional # with 479 files
running mypy --python-version 3.5 --strict-optional # with 469 files
running mypy --python-version 3.4 --strict-optional # with 469 files
running mypy --python-version 3.3 --strict-optional # with 454 files
running mypy --python-version 3.2 --strict-optional # with 453 files
running mypy --python-version 2.7 --strict-optional # with 502 files
Running pytype tests...
Ran pytype with 244 pyis, got 0 errors.
Running flake8...
flake8 run clean.
(.venv3)$
```

For mypy, if you are in the typeshed repo that is submodule of the
mypy repo (so `..` refers to the mypy repo), there's a shortcut to run
the mypy tests that avoids installing mypy:
Expand Down
2 changes: 1 addition & 1 deletion requirements-tests-py3.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mypy>=0.501
git+https://github.com/python/mypy.git@master
typed-ast>=1.0.2
flake8==3.3.0
flake8-bugbear>=17.3.0
Expand Down
6 changes: 0 additions & 6 deletions runtests.sh

This file was deleted.

0 comments on commit 761ee6a

Please sign in to comment.