Skip to content

Commit 7969ee5

Browse files
committed
No more flake8 warnings
also yapf3 formatted also changed max line length to 99 characters
1 parent b2de8bf commit 7969ee5

39 files changed

+1377
-1788
lines changed

.style.yapf

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ blank_line_before_nested_class_or_def=False
4545
coalesce_brackets=False
4646

4747
# The column limit.
48-
column_limit=79
48+
column_limit=99
4949

5050
# Indent width used for line continuations.
5151
continuation_indent_width=4

setup.cfg

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
[aliases]
22
test=pytest
3-
3+
[flake8]
4+
max-line-length=99
5+
ignore=E402,E731,E127
46

tests/aiotest/__init__.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
else:
1010
socketpair = socket.socketpair
1111

12-
import unittest
13-
try:
14-
from unittest import mock
15-
except ImportError:
16-
import mock
17-
1812

1913
class TestConfig:
2014
def __init__(self):
@@ -59,17 +53,20 @@ def __init__(self):
5953
self.stopping = True
6054

6155
def prepare(self, testcase):
62-
#import pdb;pdb.set_trace()
63-
#policy = self.new_event_pool_policy()
64-
#self.asyncio.set_event_loop_policy(policy)
56+
# import pdb;pdb.set_trace()
57+
# policy = self.new_event_pool_policy()
58+
# self.asyncio.set_event_loop_policy(policy)
6559
testcase.addCleanup(self.asyncio.set_event_loop_policy, None)
6660

6761
testcase.loop = self.asyncio.get_event_loop()
68-
#testcase.addCleanup(testcase.loop.close)
69-
#testcase.addCleanup(self.asyncio.set_event_loop, None)
62+
# testcase.addCleanup(testcase.loop.close)
63+
# testcase.addCleanup(self.asyncio.set_event_loop, None)
64+
7065

7166
class TestCase:
7267
pass
68+
69+
7370
# @classmethod
7471
# def setUpClass(cls):
7572
# cls.config = config

tests/aiotest/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from . import TestConfig
33

4+
45
@pytest.fixture
56
def config():
67
return TestConfig()
7-

tests/aiotest/test_add_reader.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
from __future__ import absolute_import
22
from tests.aiotest import socketpair
3-
from tests import aiotest
43
import pytest
54
import trio
65

6+
77
class TestAddReader:
88
@pytest.mark.trio
99
async def test_add_reader(self, loop):
1010
result = {'received': None}
1111
rsock, wsock = socketpair()
1212
ready = trio.Event()
1313
try:
14+
1415
def reader():
1516
data = rsock.recv(100)
1617
result['received'] = data
@@ -38,16 +39,19 @@ async def check_add_replace(self, event, loop, config):
3839
if event == 'reader':
3940
add_sock = loop.add_reader
4041
remove_sock = loop.remove_reader
42+
4143
def get_handle(fileobj):
4244
return selector.get_key(fileobj).data[0]
4345
else:
4446
add_sock = loop.add_writer
4547
remove_sock = loop.remove_writer
48+
4649
def get_handle(fileobj):
4750
return selector.get_key(fileobj).data[1]
4851

4952
sock = socket.socket()
5053
try:
54+
5155
def func():
5256
pass
5357

@@ -83,4 +87,3 @@ async def test_add_reader_replace(self, loop, config):
8387
@pytest.mark.trio
8488
async def test_add_writer_replace(self, loop, config):
8589
await self.check_add_replace("writer", loop, config)
86-

tests/aiotest/test_callback.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import signal
33
import pytest
44

5+
56
class TestCallback(aiotest.TestCase):
67
@pytest.mark.trio
78
async def test_call_soon(self, loop):
@@ -49,7 +50,7 @@ def world():
4950
sync_loop.call_soon(world)
5051

5152
sync_loop.run_forever()
52-
if False: # config.stopping:
53+
if False: # config.stopping:
5354
assert result == ["Hello", "World"]
5455
else:
5556
# ensure that world() is not called, since stop() was scheduled
@@ -76,7 +77,7 @@ def test():
7677
coro = test()
7778
try:
7879
# no longer depends on the loop
79-
#with pytest.raises(RuntimeError):
80+
# with pytest.raises(RuntimeError):
8081
# fut = config.asyncio.Future(loop=loop)
8182
# await loop.run_future(fut)
8283
with pytest.raises(RuntimeError, match='not a sync loop'):
@@ -99,4 +100,3 @@ def test():
99100
loop.add_signal_handler(signal.SIGTERM, func)
100101
finally:
101102
coro.close()
102-

tests/aiotest/test_coroutine.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
from tests import aiotest
22
import pytest
33

4+
45
async def hello_world(asyncio, result, delay, loop):
56
result.append("Hello")
67
# retrieve the event loop from the policy
78
await asyncio.sleep(delay, loop=loop)
89
result.append('World')
910
return "."
1011

12+
1113
class TestCoroutine(aiotest.TestCase):
1214
@pytest.mark.trio
1315
async def test_hello_world(self, loop, config):
@@ -19,7 +21,7 @@ async def test_hello_world(self, loop, config):
1921
@pytest.mark.trio
2022
async def run_hello_world(self, loop, config):
2123
result = []
22-
await loop.run_asyncio(hello_world,config.asyncio, result, 0.001, loop)
24+
await loop.run_asyncio(hello_world, config.asyncio, result, 0.001, loop)
2325
assert result == ['Hello', 'World']
2426

2527
@pytest.mark.trio
@@ -37,4 +39,3 @@ async def waiter(asyncio, hello_world, result):
3739
result = []
3840
await loop.run_asyncio(waiter, config.asyncio, hello_world, result)
3941
assert result == ['Future', 'Hello', 'World', '.']
40-

tests/aiotest/test_network.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from tests import aiotest
22
import pytest
33

4+
45
def create_classes(config):
56
asyncio = config.asyncio
67
socket = config.socket
@@ -84,4 +85,3 @@ async def test_tcp_hello(self, loop, config):
8485
await loop.stop().wait()()
8586
assert proto.state == 'closed'
8687
assert proto.received == message
87-

tests/aiotest/test_thread.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@
33
import trio
44
import trio_asyncio
55

6-
class TestThread(aiotest.TestCase):
7-
@classmethod
8-
def setUpClass(cls):
9-
super(ThreadTests, cls).setUpClass()
10-
if not cls.config.support_threads:
11-
raise aiotest.unittest.SkipTest("threads are not supported")
126

7+
class TestThread(aiotest.TestCase):
138
@pytest.mark.trio
149
async def test_ident(self, loop, config):
1510
threading = config.threading
1611
try:
17-
get_ident = threading.get_ident # Python 3
12+
get_ident = threading.get_ident # Python 3
1813
except AttributeError:
19-
get_ident = threading._get_ident # Python 2
14+
get_ident = threading._get_ident # Python 2
2015

2116
result = {'ident': None}
2217

@@ -50,7 +45,7 @@ def work():
5045
@pytest.mark.trio
5146
async def test_policy(self, loop, config):
5247
asyncio = config.asyncio
53-
result = {'loop': 'not set'} # sentinel, different than None
48+
result = {'loop': 'not set'} # sentinel, different than None
5449

5550
def work():
5651
try:
@@ -65,7 +60,6 @@ def work():
6560

6661
@pytest.mark.trio
6762
async def test_run_in_thread(self, config):
68-
asyncio = config.asyncio
6963
threading = config.threading
7064

7165
class LoopThread(threading.Thread):
@@ -105,4 +99,3 @@ def func(loop):
10599
# wait for the other thread's event loop to terminate
106100
thread.join()
107101
assert result == [tid]
108-

tests/aiotest/test_timer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pytest
44
import trio
55

6+
67
class TestTimer(aiotest.TestCase):
78
@pytest.mark.trio
89
async def test_display_date(self, loop):
@@ -44,4 +45,3 @@ def world(loop):
4445

4546
await loop.wait_stopped()
4647
assert result == ["Hello", "World"]
47-

tests/conftest.py

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import asyncio
1010
import trio_asyncio
1111

12+
1213
@pytest.fixture
1314
async def loop():
1415
async with trio_asyncio.open_loop() as loop:
@@ -17,6 +18,7 @@ async def loop():
1718
finally:
1819
await loop.stop().wait()
1920

21+
2022
@pytest.fixture
2123
def sync_loop():
2224
loop = asyncio.new_event_loop()

tests/interop/test_adapter.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import trio
55
from tests import aiotest
66

7+
78
class SomeThing:
89
flag = 0
9-
def __init__(self,loop):
10+
11+
def __init__(self, loop):
1012
self.loop = loop
1113

1214
@aio2trio
@@ -38,4 +40,3 @@ async def test_trio_asyncio(self, loop):
3840
res = await sth.dly_asyncio()
3941
assert res == 4
4042
assert sth.flag == 1
41-

0 commit comments

Comments
 (0)