Skip to content

Commit

Permalink
moving stuff around
Browse files Browse the repository at this point in the history
  • Loading branch information
zh217 committed Aug 10, 2018
1 parent 0ce1610 commit 7de924e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
5 changes: 5 additions & 0 deletions aiochan/test/test_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ def test_promise_buffer():


def test_it_buffer():
buffer = IterBuffer(())

assert not buffer.can_add
assert not buffer.can_take

buffer = IterBuffer(range(2))

assert not buffer.can_add
Expand Down
32 changes: 7 additions & 25 deletions aiochan/test/test_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def test_has_asyncio():


def test_channel_creation():
assert Chan(loop='no_loop').loop is None
assert Chan()._buf is None
assert isinstance(Chan(1)._buf, FixedLengthBuffer)
assert isinstance(Chan('f', 1)._buf, FixedLengthBuffer)
Expand Down Expand Up @@ -376,8 +377,8 @@ def topic(v):
return 'string'
elif isinstance(v, numbers.Integral):
return 'int'
else:
return 'unknown'
# else:
# return 'unknown'

p = src.pub(topic)
p.add_sub('string', a_strs, b_strs)
Expand Down Expand Up @@ -522,7 +523,7 @@ async def test_select_puts():
f = Chan().add(1).close()
e = Chan(1)

r, rc = await select(f, (e, 2))
r, rc = await select(f, (e, 2), (e, 3), (e, 4))
if rc is f:
f_hits += 1
elif rc is e:
Expand Down Expand Up @@ -693,21 +694,6 @@ async def test_combine_latest():
assert out.closed


def test_go_thread():
r = 0

async def worker():
nonlocal r
await nop()
r = 1

go_thread(worker())

time.sleep(0.01)

assert r == 1


@pytest.mark.asyncio
async def test_debounce():
c = Chan(10)
Expand All @@ -730,17 +716,13 @@ async def worker():
await nop(0.1)


def test_go_thread():
def test_go_thread1():
async def run():
await asyncio.sleep(10)
await asyncio.sleep(0)
return

go_thread(run())

with pytest.raises(AssertionError):
go_thread(run())

stop_go_thread()

# note about parallel_pipe and mode='process':
# the following tests depends on running ProcessPoolExecutor in tandem with asyncio loop.
# these are brittle, and whether they pass or not depends on how the tests are run.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ test=pytest

[tool:pytest]
;addopts = -s
;addopts = --verbose --cov=./aiochan
addopts = --verbose --cov=./aiochan

0 comments on commit 7de924e

Please sign in to comment.