Fixing flake8 warnings and errors

flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude benchmark

Excluding the benchmark directory (due to protobuf generated files)
Also removing some Python2 specific code
This commit is contained in:
Jacob Alexander
2019-09-26 22:18:28 -07:00
parent 1f0200af9c
commit b3021e4f6b
37 changed files with 536 additions and 452 deletions

View File

@@ -1,20 +1,38 @@
import capnp
import pytest
import test_capability_capnp
'''
thread test
'''
import platform
import socket
import threading
import platform
@pytest.mark.skipif(platform.python_implementation() == 'PyPy', reason="pycapnp's GIL handling isn't working properly at the moment for PyPy")
import pytest
import capnp
import test_capability_capnp
@pytest.mark.skipif(
platform.python_implementation() == 'PyPy',
reason="pycapnp's GIL handling isn't working properly at the moment for PyPy"
)
def test_making_event_loop():
'''
Event loop test
'''
capnp.remove_event_loop(True)
capnp.create_event_loop()
capnp.remove_event_loop()
capnp.create_event_loop()
@pytest.mark.skipif(platform.python_implementation() == 'PyPy', reason="pycapnp's GIL handling isn't working properly at the moment for PyPy")
@pytest.mark.skipif(
platform.python_implementation() == 'PyPy',
reason="pycapnp's GIL handling isn't working properly at the moment for PyPy"
)
def test_making_threaded_event_loop():
'''
Threaded event loop test
'''
capnp.remove_event_loop(True)
capnp.create_event_loop(True)
@@ -23,23 +41,40 @@ def test_making_threaded_event_loop():
class Server(test_capability_capnp.TestInterface.Server):
'''
Server
'''
def __init__(self, val=1):
self.val = val
def foo(self, i, j, **kwargs):
'''
foo
'''
return str(i * 5 + self.val)
class SimpleRestorer(test_capability_capnp.TestSturdyRefObjectId.Restorer):
'''
SimpleRestorer
'''
def restore(self, ref_id):
'''
Restore
'''
assert ref_id.tag == 'testInterface'
return Server(100)
@pytest.mark.skipif(platform.python_implementation() == 'PyPy', reason="pycapnp's GIL handling isn't working properly at the moment for PyPy")
@pytest.mark.skipif(
platform.python_implementation() == 'PyPy',
reason="pycapnp's GIL handling isn't working properly at the moment for PyPy"
)
def test_using_threads():
'''
Thread test
'''
capnp.remove_event_loop(True)
capnp.create_event_loop(True)
@@ -47,7 +82,7 @@ def test_using_threads():
def run_server():
restorer = SimpleRestorer()
server = capnp.TwoPartyServer(write, restorer)
_ = capnp.TwoPartyServer(write, restorer)
capnp.wait_forever()
server_thread = threading.Thread(target=run_server)