Skip to content

Commit 99aef6d

Browse files
committed
Merge the work required to get the Travis tests to run.
TODO: resolve some of the more interesting failures.
2 parents c7dcec4 + 8d2f11e commit 99aef6d

12 files changed

Lines changed: 92 additions & 141 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/.eggs/
66
/.pybuild/
77
/build/
8+
/docs/build/
89
__pycache__/
910
/trio_asyncio.egg-info/
1011
/.pybuild/

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ dist: trusty
88

99
matrix:
1010
include:
11-
- os: linux
12-
language: generic
13-
env: USE_PYPY_RELEASE_VERSION=5.9-beta
11+
# - os: linux
12+
# language: generic
13+
# env: USE_PYPY_RELEASE_VERSION=5.9-beta
1414
# Uncomment if you want to test on pypy nightly
1515
# - os: linux
1616
# language: generic

CHEATSHEET.rst

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,25 @@
1-
Finishing setting up your project
2-
=================================
3-
4-
Thanks for using cookiecutter-trio! This is your project now; you can
5-
customize it however you like. Here's some reminders of things you
6-
might want to do to get started:
7-
8-
* Check this into source control (``git init .; git add .; git
9-
commit -m "Initial commit"``)
10-
11-
* Add a CODE_OF_CONDUCT.md
12-
13-
* Add a CONTRIBUTING.md
14-
15-
* Search the source tree for COOKIECUTTER-TRIO-TODO to find other
16-
places to fill in.
17-
* Enable `Read the Docs <https://readthedocs.org>`__. (Note: this
18-
project contains a ``.readthedocs.yml`` file that should be enough
19-
to get things working.)
20-
21-
* Set up continuous integration: Currently, this project is set up to
22-
test on Linux and MacOS using Travis, on Windows using Appveyor, and
23-
to test on PyPy.
24-
25-
If that's what you want, then go to Travis and Appveyor and enable
26-
testing for your repo.
27-
28-
If that's not what you want, then you can trim the list by modifying
29-
(or deleting) ``.travis.yml``, ``.appveyor.yml``, ``ci/travis.sh``.
30-
31-
* Enable `Codecov <https://codecov.io>`__ for your repo.
32-
33-
* File bugs or pull requests on `cookiecutter-trio
34-
<https://github.com/python-trio/cookiecutter-trio>`__ reporting any
35-
problems or awkwardness you ran into (no matter how small!)
36-
37-
* Delete this checklist once it's no longer useful
38-
39-
401
Tips
412
====
423

434
To run tests
445
------------
456

46-
* Install requirements: ``pip install -r test-requirements.txt``
7+
* Install requirements: ``pip install -r ci/test-requirements.txt``
478
(possibly in a virtualenv)
489

49-
* Actually run the tests: ``pytest trio_asyncio``
10+
* Actually run the tests: ``PYTHONPATH=. pytest-3 tests``
5011

5112

5213
To run yapf
5314
-----------
5415

55-
* Show what changes yapf wants to make: ``yapf -rpd setup.py
56-
trio_asyncio``
16+
* Show what changes yapf wants to make:
17+
``yapf3 -rpd setup.py trio_asyncio tests``
5718

58-
* Apply all changes directly to the source tree: ``yapf -rpi setup.py
59-
trio_asyncio``
19+
* Apply all changes directly to the source tree:
20+
``yapf -rpi setup.py trio_asyncio tests``
21+
22+
* Find semantic problems: ``flake8 setup.py trio_asyncio tests``
6023

6124

6225
To make a release
@@ -72,10 +35,7 @@ To make a release
7235

7336
* Double-check it all works, docs build, etc.
7437

75-
* Build your sdist and wheel: ``python setup.py sdist bdist_wheel``
76-
77-
* Upload to PyPI: ``twine upload dist/*``
78-
79-
* Use ``git tag`` to tag your version.
38+
* Upload to PyPI: ``make upload``
8039

8140
* Don't forget to ``git push --tags``.
41+

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ SPHINXBUILDDIR ?= $(BUILD_DIR)/sphinx/html
3333
ALLSPHINXOPTS ?= -d $(BUILD_DIR)/sphinx/doctrees $(SPHINXOPTS) docs
3434

3535
doc:
36-
sphinx-build -a $(INPUT_DIR) build
36+
sphinx3-build -a $(INPUT_DIR) $(BUILD_DIR)
3737

3838
livehtml: docs
3939
sphinx-autobuild $(AUTOSPHINXOPTS) $(ALLSPHINXOPTS) $(SPHINXBUILDDIR)
@@ -52,8 +52,8 @@ pypi: tag
5252
## version depends on tag, so re-tagging doesn't make sense
5353

5454
upload: pypi
55-
git push --tags
55+
git push-all --tags
5656

5757
update:
58-
pip install -r requirements_dev.txt
58+
pip install -r ci/test-requirements.txt
5959

tests/aiotest/test_timer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ class TestTimer(aiotest.TestCase):
88
@pytest.mark.trio
99
async def test_display_date(self, loop):
1010
result = []
11-
delay = 0.050
11+
delay = 0.1
1212
count = 3
1313
h = trio.Event()
1414

1515
def display_date(end_time, loop):
1616
if not end_time:
1717
end_time.append(loop.time() + delay * count)
1818
result.append(datetime.datetime.now())
19-
if (loop.time() + delay) < end_time[0]:
19+
if (loop.time() + delay*1.5) < end_time[0]:
2020
loop.call_later(delay, display_date, end_time, loop)
2121
else:
2222
loop.stop(h)

tests/conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,18 @@
77
import pytest
88
import asyncio
99
import trio_asyncio
10+
import inspect
1011

12+
# Hacks for <3.7
13+
if not hasattr(asyncio,'current_task'):
14+
def current_task(loop=None):
15+
return asyncio.Task.current_task(loop)
16+
asyncio.current_task = current_task
17+
18+
if not hasattr(asyncio,'all_tasks'):
19+
def all_tasks(loop=None):
20+
return asyncio.Task.all_tasks(loop)
21+
asyncio.all_tasks = all_tasks
1122

1223
@pytest.fixture
1324
async def loop():
@@ -23,3 +34,10 @@ def sync_loop():
2334
loop = asyncio.new_event_loop()
2435
with loop:
2536
yield loop
37+
38+
# auto-trio-ize all async functions
39+
@pytest.hookimpl(tryfirst=True)
40+
def pytest_pyfunc_call(pyfuncitem):
41+
if inspect.iscoroutinefunction(pyfuncitem.obj):
42+
pyfuncitem.obj = pytest.mark.trio(pyfuncitem.obj)
43+

tests/python/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ def load_tests(*args):
99
return load_package_tests(os.path.dirname(__file__), *args)
1010

1111

12-
import asyncio.tasks
13-
asyncio.tasks.Task = asyncio.tasks._PyTask
14-
import asyncio.futures
15-
asyncio.futures.Future = asyncio.futures._PyFuture
16-
#
17-
#
1812
# this code is from
1913
# git@github.com:python/cpython.git
2014
# Revision d48ecebad

tests/python/test_base_events.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ def test_thread(loop, debug, create_loop=False):
345345
# check disabled if debug mode is disabled
346346
test_thread(self.loop, False, create_loop=True)
347347

348+
@unittest.skipIf(sys.version_info >= (3, 7), "deleted")
348349
def test_run_once_in_executor_plain(self):
349350
def cb():
350351
pass

tests/python/test_events.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,7 @@ def test_legacy_create_unix_server_ssl_verified(self):
11761176
with test_utils.force_legacy_ssl_support():
11771177
self.test_create_unix_server_ssl_verified()
11781178

1179+
@pytest.mark.xfail(sys.version_info > (3, 7), reason="XXX to be investigated")
11791180
@unittest.skipIf(ssl is None, 'No ssl module')
11801181
def test_create_server_ssl_verified(self):
11811182
proto = MyProto(loop=self.loop)

tests/python/test_pep492.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_context_manager_with_await(self):
5959
async def test(lock):
6060
await asyncio.sleep(0.01, loop=self.loop)
6161
self.assertFalse(lock.locked())
62-
with await lock as _lock:
62+
async with lock as _lock:
6363
self.assertIs(_lock, None)
6464
self.assertTrue(lock.locked())
6565
await asyncio.sleep(0.01, loop=self.loop)

0 commit comments

Comments
 (0)