Skip to content

Commit

Permalink
Keep pycodestyle happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Booth committed Mar 15, 2018
1 parent 78fc198 commit 704ef00
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#

#import os
#import sys
#sys.path.insert(0, os.path.abspath('..'))
#import aiorpcx
# import os
# import sys
# sys.path.insert(0, os.path.abspath('..'))
# import aiorpcx


# -- Project information -----------------------------------------------------
Expand Down
15 changes: 8 additions & 7 deletions tests/test_socks.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def data_received(self, data):
self.buff += data
try:
self.consume_func()
except:
except Exception:
traceback.print_exc()

def close(self, data=None):
Expand Down Expand Up @@ -170,7 +170,6 @@ def SOCKS5_auth(self, auth_response, req_response, split):
self.split_write(auth_response, split)
self.consume_func = partial(self.SOCKS5_req, req_response, split)


def SOCKS5_req(self, req_response, split):
if len(self.buff) < 4:
return
Expand Down Expand Up @@ -304,11 +303,13 @@ def with_timeout(timeout, loop, coro):
with Timeout(0.05, loop) as t:
return loop.run_until_complete(t.run(coro))


async def connecta(protocol, lss, consume_func, auth, addr, received=None):
lss.server.consume_func = consume_func
await protocol.handshake(lss.socket, *addr, auth, loop=lss.loop)
assert lss.server.received == received


def connect(protocol, lss, consume_func, auth, addr, received=None):
coro = connecta(protocol, lss, consume_func, auth, addr, received)
lss.loop.run_until_complete(coro)
Expand Down Expand Up @@ -478,28 +479,28 @@ def test_short_username(self, lss5, addr5):
auth = SOCKSUserAuth(username='', password='password')
with pytest.raises(SOCKSFailure) as err:
connect(SOCKS5, lss5, partial(lss5.server.SOCKS5, chosen_auth=2),
auth, addr5)
auth, addr5)
assert 'invalid username' in str(err.value)

def test_long_username(self, lss5, addr5):
auth = SOCKSUserAuth(username='a' * 256, password='password')
with pytest.raises(SOCKSFailure) as err:
connect(SOCKS5, lss5, partial(lss5.server.SOCKS5, chosen_auth=2),
auth, addr5)
auth, addr5)
assert 'invalid username' in str(err.value)

def test_short_password(self, lss5, addr5):
auth = SOCKSUserAuth(username='username', password='')
with pytest.raises(SOCKSFailure) as err:
connect(SOCKS5, lss5, partial(lss5.server.SOCKS5, chosen_auth=2),
auth, addr5)
auth, addr5)
assert 'invalid password' in str(err.value)

def test_long_password(self, lss5, addr5):
auth = SOCKSUserAuth(username='username', password='p' * 256)
with pytest.raises(SOCKSFailure) as err:
connect(SOCKS5, lss5, partial(lss5.server.SOCKS5, chosen_auth=2),
auth, addr5)
auth, addr5)
assert 'invalid password' in str(err.value)

def test_reject_auth(self, lss5, addr5):
Expand Down Expand Up @@ -682,7 +683,7 @@ def test_good_SOCKS4a(self, SOCKS4a_address, auth):

# def test_good_SOCKS4(self, SOCKS4_address, auth):
# loop = asyncio.get_event_loop()
# coro = SOCKSProxy.auto_detect_address(SOCKS4_address, auth, loop=None)
# coro = SOCKSProxy.auto_detect_address(SOCKS4_address, auth, loop=None)
# loop = asyncio.get_event_loop()
# result = loop.run_until_complete(coro)
# assert isinstance(result, SOCKSProxy)
Expand Down

0 comments on commit 704ef00

Please sign in to comment.