Skip to content

Commit

Permalink
Renamed the project to "anyio"
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Oct 7, 2018
1 parent 6bfc33c commit 0a78961
Show file tree
Hide file tree
Showing 21 changed files with 77 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
distributions: sdist bdist_wheel
on:
tags: true
repo: agronholm/hyperio
repo: agronholm/anyio
allow_failures:
- python: pypy3

Expand Down
8 changes: 5 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
.. image:: https://travis-ci.org/agronholm/hyperio.svg?branch=master
:target: https://travis-ci.org/agronholm/hyperio
.. image:: https://travis-ci.com/agronholm/anyio.svg?branch=master
:target: https://travis-ci.com/agronholm/anyio
:alt: Build Status

HyperIO is a asynchronous compatibility API that allows applications and libraries written against
AnyIO is a asynchronous compatibility API that allows applications and libraries written against
it to run unmodified on asyncio_, curio_ and trio_.

It bridges the following functionality:

* Task groups
* Cancellation
* Threads
* Signal handling
* Asynchronous file I/O
* Synchronization primitives (locks, conditions, events, semaphores, queues)
* High level networking (TCP, UDP and UNIX sockets)

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions hyperio/abc.py → anyio/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ async def receive_exactly(self, nbytes: int) -> bytes:
:param nbytes: the number of bytes to read
:return: the bytes read
:raises hyperio.exceptions.IncompleteRead: if the stream was closed before the requested
:raises anyio.exceptions.IncompleteRead: if the stream was closed before the requested
amount of bytes could be read from the stream
"""

Expand All @@ -341,9 +341,9 @@ async def receive_until(self, delimiter: bytes, max_bytes: int) -> bytes:
:param delimiter: the marker to look for in the stream
:param max_bytes: maximum number of bytes that will be read before raising
:exc:`~hyperio.exceptions.DelimiterNotFound`
:exc:`~anyio.exceptions.DelimiterNotFound`
:return: the bytes read, including the delimiter
:raises hyperio.exceptions.DelimiterNotFound: if the delimiter is not found within the
:raises anyio.exceptions.DelimiterNotFound: if the delimiter is not found within the
bytes read up to the maximum allowed
"""

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 15 additions & 15 deletions hyperio/pytest_plugin.py → anyio/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

import hyperio
import anyio

try:
from async_generator import isasyncgenfunction
Expand All @@ -14,34 +14,34 @@
@pytest.hookimpl(hookwrapper=True)
def pytest_fixture_setup(fixturedef, request):
def wrapper(*args, **kwargs):
backend = kwargs['hyperio_backend']
backend = kwargs['anyio_backend']
if strip_backend:
del kwargs['hyperio_backend']
del kwargs['anyio_backend']

if isasyncgenfunction(func):
gen = func(*args, **kwargs)
try:
value = hyperio.run(gen.__anext__, backend=backend)
value = anyio.run(gen.__anext__, backend=backend)
except StopAsyncIteration:
raise RuntimeError('Async generator did not yield')

yield value

try:
hyperio.run(gen.__anext__, backend=backend)
anyio.run(gen.__anext__, backend=backend)
except StopAsyncIteration:
pass
else:
hyperio.run(gen.aclose)
anyio.run(gen.aclose)
raise RuntimeError('Async generator fixture did not stop')
else:
yield hyperio.run(partial(func, *args, **kwargs), backend=backend)
yield anyio.run(partial(func, *args, **kwargs), backend=backend)

func = fixturedef.func
if isasyncgenfunction(func) or iscoroutinefunction(func):
strip_backend = False
if 'hyperio_backend' not in fixturedef.argnames:
fixturedef.argnames += ('hyperio_backend',)
if 'anyio_backend' not in fixturedef.argnames:
fixturedef.argnames += ('anyio_backend',)
strip_backend = True

fixturedef.func = wrapper
Expand All @@ -50,18 +50,18 @@ def wrapper(*args, **kwargs):


def pytest_generate_tests(metafunc):
marker = metafunc.definition.get_closest_marker('hyperio')
marker = metafunc.definition.get_closest_marker('anyio')
if marker:
backends = marker.kwargs.get('backends', ['asyncio', 'curio', 'trio'])
metafunc.fixturenames.append('hyperio_backend')
metafunc.parametrize('hyperio_backend', backends, scope='session')
metafunc.fixturenames.append('anyio_backend')
metafunc.parametrize('anyio_backend', backends, scope='session')


@pytest.mark.tryfirst
def pytest_pyfunc_call(pyfuncitem):
if pyfuncitem.get_closest_marker('hyperio'):
if pyfuncitem.get_closest_marker('anyio'):
funcargs = pyfuncitem.funcargs
backend = pyfuncitem._request.getfixturevalue('hyperio_backend')
backend = pyfuncitem._request.getfixturevalue('anyio_backend')
testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames}
hyperio.run(partial(pyfuncitem.obj, **testargs), backend=backend)
anyio.run(partial(pyfuncitem.obj, **testargs), backend=backend)
return True
File renamed without changes.
10 changes: 5 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[metadata]
name = hyperio
name = anyio
description =
long_description = file: README.rst
author = Alex Grönholm
author_email = [email protected]
project_urls =
Source code = https://github.com/agronholm/hyperio
Issue tracker = https://github.com/agronholm/hyperio/issues
Source code = https://github.com/agronholm/anyio
Issue tracker = https://github.com/agronholm/anyio/issues
license = MIT
license_file = LICENSE
classifiers =
Expand Down Expand Up @@ -34,14 +34,14 @@ curio = curio >= 0.9

[options.entry_points]
pytest11 =
hyperio = hyperio.pytest_plugin
anyio = anyio.pytest_plugin

[tool:pytest]
;addopts = -rsx --tb=short --cov
testpaths = tests

[coverage:run]
source = hyperio
source = anyio

[coverage:report]
show_missing = true
Expand Down
8 changes: 4 additions & 4 deletions tests/test_fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from hyperio import aopen
from anyio import aopen


@pytest.fixture(scope='module')
Expand All @@ -17,7 +17,7 @@ def testdatafile(tmpdir_factory, testdata):
return Path(str(file))


@pytest.mark.hyperio
@pytest.mark.anyio
async def test_read(testdatafile, testdata):
async with await aopen(testdatafile, 'rb') as f:
data = await f.read()
Expand All @@ -26,15 +26,15 @@ async def test_read(testdatafile, testdata):
assert data == testdata


@pytest.mark.hyperio
@pytest.mark.anyio
async def test_write(testdatafile, testdata):
async with await aopen(testdatafile, 'ab') as f:
await f.write(b'f' * 1000)

assert testdatafile.stat().st_size == len(testdata) + 1000


@pytest.mark.hyperio
@pytest.mark.anyio
async def test_async_iteration(tmpdir):
lines = ['blah blah\n', 'foo foo\n', 'bar bar']
testpath = tmpdir.join('testfile')
Expand Down
12 changes: 6 additions & 6 deletions tests/test_networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

import pytest

from hyperio import (
from anyio import (
create_task_group, connect_tcp, create_udp_socket, connect_unix, create_unix_server,
create_tcp_server)


@pytest.mark.hyperio
@pytest.mark.anyio
async def test_connect_tcp():
async def server():
async with await stream_server.accept() as stream:
Expand All @@ -26,7 +26,7 @@ async def server():
assert response == b'halb'


@pytest.mark.hyperio
@pytest.mark.anyio
async def test_connect_tcp_tls():
async def server():
async with await stream_server.accept() as stream:
Expand All @@ -52,7 +52,7 @@ async def server():

@pytest.mark.skipif(os.name == 'nt', reason='UNIX sockets are not available on Windows')
@pytest.mark.parametrize('as_path', [False])
@pytest.mark.hyperio
@pytest.mark.anyio
async def test_connect_unix(tmpdir, as_path):
async def server():
async with await stream_server.accept() as stream:
Expand All @@ -77,7 +77,7 @@ async def server():
('receive_until', [b'\n', 100]),
('receive_exactly', [5])
], ids=['read_until', 'read_exactly'])
@pytest.mark.hyperio
@pytest.mark.anyio
async def test_read_partial(method_name, params):
async def server():
async with await stream_server.accept() as stream:
Expand All @@ -98,7 +98,7 @@ async def server():
assert response == b'blahbleh'


@pytest.mark.hyperio
@pytest.mark.anyio
async def test_udp():
async with await create_udp_socket(port=5000, interface='localhost',
target_port=5000, target_host='localhost') as socket:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_pytest_plugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from async_generator import async_generator, yield_

from hyperio import sleep
from anyio import sleep


@pytest.fixture
Expand All @@ -18,11 +18,11 @@ async def asyncgen_fixture():
await sleep(0)


@pytest.mark.hyperio(backends=['asyncio'])
@pytest.mark.anyio(backends=['asyncio'])
async def test_fixture(async_fixture):
assert async_fixture == 'foo'


@pytest.mark.hyperio
@pytest.mark.anyio
async def test_asyncgen_fixture(asyncgen_fixture):
assert asyncgen_fixture == 'foo'
4 changes: 2 additions & 2 deletions tests/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

import pytest

from hyperio import receive_signals
from anyio import receive_signals


@pytest.mark.skipif(os.name == 'nt', reason='Signal delivery cannot be tested on Windows')
@pytest.mark.hyperio
@pytest.mark.anyio
async def test_receive_signals():
async with receive_signals(signal.SIGUSR1, signal.SIGUSR2) as sigiter:
os.kill(os.getpid(), signal.SIGUSR1)
Expand Down
24 changes: 12 additions & 12 deletions tests/test_synchronization.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import pytest

from hyperio import (
from anyio import (
create_lock, create_task_group, sleep, create_queue, create_event, create_semaphore,
create_condition, open_cancel_scope)


class TestLock:
@pytest.mark.hyperio
@pytest.mark.anyio
async def test_lock(self):
async def task():
assert lock.locked()
Expand All @@ -24,7 +24,7 @@ async def task():
assert not lock.locked()
assert results == ['1', '2']

@pytest.mark.hyperio
@pytest.mark.anyio
async def test_lock_cancel(self):
async def task():
nonlocal task_started, got_lock
Expand All @@ -44,7 +44,7 @@ async def task():


class TestEvent:
@pytest.mark.hyperio
@pytest.mark.anyio
async def test_event(self):
async def setter():
assert not event.is_set()
Expand All @@ -58,7 +58,7 @@ async def setter():

assert not event.is_set()

@pytest.mark.hyperio
@pytest.mark.anyio
async def test_event_cancel(self):
async def task():
nonlocal task_started, event_set
Expand All @@ -78,7 +78,7 @@ async def task():


class TestCondition:
@pytest.mark.hyperio
@pytest.mark.anyio
async def test_condition(self):
async def notifier():
async with condition:
Expand All @@ -91,7 +91,7 @@ async def notifier():
await tg.spawn(notifier)
await condition.wait()

@pytest.mark.hyperio
@pytest.mark.anyio
async def test_wait_cancel(self):
async def task():
nonlocal task_started, notified
Expand All @@ -117,7 +117,7 @@ async def task():


class TestSemaphore:
@pytest.mark.hyperio
@pytest.mark.anyio
async def test_semaphore(self):
async def acquire():
async with semaphore:
Expand All @@ -130,7 +130,7 @@ async def acquire():

assert semaphore.value == 2

@pytest.mark.hyperio
@pytest.mark.anyio
async def test_acquire_cancel(self):
async def task():
nonlocal local_scope, acquired
Expand All @@ -151,7 +151,7 @@ async def task():


class TestQueue:
@pytest.mark.hyperio
@pytest.mark.anyio
async def test_queue(self):
queue = create_queue(1)
assert queue.empty()
Expand All @@ -161,7 +161,7 @@ async def test_queue(self):
assert await queue.get() == '1'
assert queue.empty()

@pytest.mark.hyperio
@pytest.mark.anyio
async def test_get_cancel(self):
async def task():
nonlocal local_scope
Expand All @@ -180,7 +180,7 @@ async def task():

assert queue.full()

@pytest.mark.hyperio
@pytest.mark.anyio
async def test_put_cancel(self):
async def task():
nonlocal local_scope
Expand Down
Loading

0 comments on commit 0a78961

Please sign in to comment.