|
1 | 1 | #!/bin/sh
|
2 |
| -set -e |
3 |
| -DATABASE_URL=postgres://jrandom@localhost/test py.test tests.py -v |
4 |
| -echo "Starting doctests." |
5 |
| -python postgres/__init__.py |
6 |
| -python postgres/cursors.py |
7 |
| -python postgres/orm.py |
8 |
| -echo "" |
9 |
| -python --version 2>&1 | grep 'Python 3' > /dev/null && \ |
10 |
| - echo "\x1b[31mYou may see errors\x1b[0m due to dict ordering not being stable." |
11 |
| -python --version 2>&1 | grep 'Python 2' > /dev/null && \ |
12 |
| - echo "\x1b[31mYou're using Python 2.\x1b[0m Expect errors comparing '' and u''." && \ |
13 |
| - echo "You may also see errors due to dict ordering not being stable." |
14 |
| -echo "We don't fix these because that would make docs uglier." |
15 |
| -echo "" |
16 |
| -echo "Done with doctests." |
| 2 | + |
| 3 | +# Run both pytests and doctests, but only vary the return code on the result of |
| 4 | +# the pytests. The doctests can fail for spurious reasons, and we chose not to |
| 5 | +# fix them because fixing them would make the docs uglier. As long as the |
| 6 | +# doctests pass for Python 3 then we know the doc examples are good. |
| 7 | + |
| 8 | +function run_pytests() { |
| 9 | + DATABASE_URL=postgres://jrandom@localhost/test py.test tests.py -v && return 0 || return 1 |
| 10 | +} |
| 11 | + |
| 12 | +function run_doctests() { |
| 13 | + echo "Starting doctests." |
| 14 | + python postgres/__init__.py |
| 15 | + python postgres/cursors.py |
| 16 | + python postgres/orm.py |
| 17 | + echo "" |
| 18 | + python --version 2>&1 | grep 'Python 3' > /dev/null && \ |
| 19 | + echo "\x1b[31mYou may see errors\x1b[0m due to dict ordering not being stable." |
| 20 | + python --version 2>&1 | grep 'Python 2' > /dev/null && \ |
| 21 | + echo "\x1b[31mYou're using Python 2.\x1b[0m Expect errors comparing '' and u''." && \ |
| 22 | + echo "You may also see errors due to dict ordering not being stable." |
| 23 | + echo "We don't fix these because that would make docs uglier." |
| 24 | + echo "" |
| 25 | + echo "Done with doctests." |
| 26 | + |
| 27 | + return 0 # Always report success, because we don't want Travis to choke on u''. |
| 28 | +} |
| 29 | + |
| 30 | +run_pytests |
| 31 | +SUCCESS=$? |
| 32 | + |
| 33 | +run_doctests |
| 34 | +exit $SUCCESS |
0 commit comments