Run black on sources; add black config

This commit is contained in:
Griatch 2020-07-27 21:12:06 +02:00
parent b5d148b00a
commit b24d4f0e1e
41 changed files with 400 additions and 344 deletions

View file

@ -467,7 +467,11 @@ def getKeyPair(pubkeyfile, privkeyfile):
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa
rsa_key = Key(rsa.generate_private_key(public_exponent=65537, key_size=_KEY_LENGTH, backend=default_backend()))
rsa_key = Key(
rsa.generate_private_key(
public_exponent=65537, key_size=_KEY_LENGTH, backend=default_backend()
)
)
public_key_string = rsa_key.public().toString(type="OPENSSH").decode()
private_key_string = rsa_key.toString(type="OPENSSH").decode()

View file

@ -1,4 +1,3 @@
try:
from django.utils.unittest import TestCase
except ImportError:
@ -290,7 +289,7 @@ class TestWebSocket(EvenniaTest):
self.proto.sessionhandler = PORTAL_SESSIONS
self.proto.sessionhandler.portal = Mock()
self.proto.transport = proto_helpers.StringTransport()
#self.proto.transport = proto_helpers.FakeDatagramTransport()
# self.proto.transport = proto_helpers.FakeDatagramTransport()
self.proto.transport.client = ["localhost"]
self.proto.transport.setTcpKeepAlive = Mock()
self.proto.state = MagicMock()
@ -318,4 +317,4 @@ class TestWebSocket(EvenniaTest):
self.proto.sendLine = MagicMock()
msg = json.dumps(["logged_in", (), {}])
self.proto.sessionhandler.data_out(self.proto, text=[["Excepting Alice"], {}])
self.proto.sendLine.assert_called_with(json.dumps(['text', ['Excepting Alice'], {}]))
self.proto.sendLine.assert_called_with(json.dumps(["text", ["Excepting Alice"], {}]))

View file

@ -132,7 +132,7 @@ def _server_maintenance():
else:
# adjust the runtime not with 60s but with the actual elapsed time
# in case this may varies slightly from 60s.
_GAMETIME_MODULE.SERVER_RUNTIME += (now - _LAST_SERVER_TIME_SNAPSHOT)
_GAMETIME_MODULE.SERVER_RUNTIME += now - _LAST_SERVER_TIME_SNAPSHOT
_LAST_SERVER_TIME_SNAPSHOT = now
# update game time and save it across reloads

View file

@ -221,9 +221,7 @@ class SessionHandler(dict):
elif isinstance(data, (str, bytes)):
data = _utf8(data)
if (_INLINEFUNC_ENABLED
and not raw
and isinstance(self, ServerSessionHandler)):
if _INLINEFUNC_ENABLED and not raw and isinstance(self, ServerSessionHandler):
# only parse inlinefuncs on the outgoing path (sessionhandler->)
data = parse_inlinefunc(data, strip=strip_inlinefunc, session=session)

View file

@ -26,6 +26,7 @@ class EvenniaTestSuiteRunner(DiscoverRunner):
# can't mock it - instead we stop it before starting the test - otherwise
# we'd get unclean reactor errors across test boundaries.
from evennia.server.portal.portal import PORTAL
PORTAL.maintenance_task.stop()
import evennia
@ -34,4 +35,3 @@ class EvenniaTestSuiteRunner(DiscoverRunner):
return super(EvenniaTestSuiteRunner, self).build_suite(
test_labels, extra_tests=extra_tests, **kwargs
)