python3: clean up class brackets

This commit is contained in:
Aldo Cortesi 2016-10-17 17:29:45 +13:00
parent fb22f2ff4f
commit a647b30365
69 changed files with 122 additions and 122 deletions

View File

@ -15,7 +15,7 @@ import os
import sys
class Wrapper():
class Wrapper:
def __init__(self, port, extra_arguments=None):
self.port = port
self.extra_arguments = extra_arguments

View File

@ -38,7 +38,7 @@ class InterceptionResult(Enum):
skipped = None
class _TlsStrategy():
class _TlsStrategy:
"""
Abstract base class for interception strategies.
"""

View File

@ -7,7 +7,7 @@ def _get_name(itm):
return getattr(itm, "name", itm.__class__.__name__.lower())
class Addons():
class Addons:
def __init__(self, master):
self.chain = []
self.master = master

View File

@ -20,7 +20,7 @@ def indent(n, text):
return "\n".join(pad + i for i in l)
class Dumper():
class Dumper:
def __init__(self):
self.filter = None # type: flowfilter.TFilter
self.flow_detail = None # type: int

View File

@ -215,7 +215,7 @@ class Script:
self.dead = True
class ScriptLoader():
class ScriptLoader:
"""
An addon that manages loading scripts from options.
"""

View File

@ -6,7 +6,7 @@ from netlib import strutils
from mitmproxy import exceptions, flow, ctx
class ServerPlayback():
class ServerPlayback:
def __init__(self):
self.options = None

View File

@ -26,7 +26,7 @@ class Column(col_bytes.Column):
# This is the same for both edit and display.
class EncodingMixin():
class EncodingMixin:
def __init__(self, data, encoding_args):
# type: (str) -> TDisplay
self.encoding_args = encoding_args

View File

@ -93,7 +93,7 @@ def format_text(text):
yield [("text", line)]
class View():
class View:
name = None
prompt = ()
content_types = []

View File

@ -41,13 +41,13 @@ Events = frozenset([
])
class LogEntry():
class LogEntry:
def __init__(self, msg, level):
self.msg = msg
self.level = level
class Log():
class Log:
"""
The central logger, exposed to scripts as mitmproxy.ctx.log.
"""
@ -82,7 +82,7 @@ class Log():
self.master.add_log(text, level)
class Master():
class Master:
"""
The master handles mitmproxy's main event loop.
"""
@ -185,7 +185,7 @@ class ServerThread(basethread.BaseThread):
self.server.serve_forever()
class Channel():
class Channel:
"""
The only way for the proxy server to communicate with the master
is to use the channel it has been given.
@ -272,7 +272,7 @@ def handler(f):
NO_REPLY = object() # special object we can distinguish from a valid "None" reply.
class Reply():
class Reply:
"""
Messages sent through a channel are decorated with a "reply" attribute.
This object is used to respond to the message through the return

View File

@ -32,7 +32,7 @@ class AppRegistry:
return self.apps.get((host, request.port), None)
class StreamLargeBodies():
class StreamLargeBodies:
def __init__(self, max_size):
self.max_size = max_size

View File

@ -177,7 +177,7 @@ class FlowStore(FlowList):
f.kill(master)
class State():
class State:
def __init__(self):
self.flows = FlowStore()
self.view = FlowView(self.flows, None)

View File

@ -58,7 +58,7 @@ def only(*types):
return decorator
class _Token():
class _Token:
def dump(self, indent=0, fp=sys.stdout):
print("{spacing}{name}{expr}".format(

View File

@ -11,7 +11,7 @@ from mitmproxy import exceptions
"""
class OptManager():
class OptManager:
"""
.changed is a blinker Signal that triggers whenever options are
updated. If any handler in the chain raises an exceptions.OptionsError

View File

@ -5,7 +5,7 @@ import struct
SO_ORIGINAL_DST = 80
class Resolver():
class Resolver:
def original_addr(self, csock):
odestdata = csock.getsockopt(socket.SOL_IP, SO_ORIGINAL_DST, 16)

View File

@ -15,7 +15,7 @@ from . import pf
"""
class Resolver():
class Resolver:
STATECMD = ("sudo", "-n", "/sbin/pfctl", "-s", "state")
def original_addr(self, csock):

View File

@ -16,7 +16,7 @@ import socketserver
PROXY_API_PORT = 8085
class Resolver():
class Resolver:
def __init__(self):
TransparentProxy.setup()
@ -111,7 +111,7 @@ def MIB_TCPTABLE2(size):
return _MIB_TCPTABLE2()
class TransparentProxy():
class TransparentProxy:
"""
Transparent Windows Proxy for mitmproxy based on WinDivert/PyDivert.

View File

@ -5,7 +5,7 @@ from mitmproxy import exceptions
from mitmproxy import models
class _LayerCodeCompletion():
class _LayerCodeCompletion:
"""
Dummy class that provides type hinting in PyCharm, which simplifies development a lot.
@ -88,7 +88,7 @@ class Layer(_LayerCodeCompletion):
return type(self).__name__
class ServerConnectionMixin():
class ServerConnectionMixin:
"""
Mixin that provides a layer with the capabilities to manage a server connection.

View File

@ -61,7 +61,7 @@ class _HttpTransmissionLayer(base.Layer):
raise NotImplementedError()
class ConnectServerConnection():
class ConnectServerConnection:
"""
"Fake" ServerConnection to represent state after a CONNECT request to an upstream proxy.

View File

@ -248,7 +248,7 @@ def get_client_hello(client_conn):
return client_hello
class TlsClientHello():
class TlsClientHello:
def __init__(self, raw_client_hello):
self._client_hello = _constructs.ClientHello.parse(raw_client_hello)

View File

@ -20,7 +20,7 @@ from netlib.http import url
CONF_BASENAME = "mitmproxy"
class HostMatcher():
class HostMatcher:
def __init__(self, patterns=tuple()):
self.patterns = list(patterns)

View File

@ -7,7 +7,7 @@ from mitmproxy import protocol
from mitmproxy.proxy import modes
class RootContext():
class RootContext:
"""
The outermost context provided to the root layer.

View File

@ -62,7 +62,7 @@ class ProxyServer(tcp.TCPServer):
h.handle()
class ConnectionHandler():
class ConnectionHandler:
def __init__(self, client_conn, client_address, config, channel):
self.config = config

View File

@ -73,7 +73,7 @@ class APIError(tornado.web.HTTPError):
pass
class BasicAuth():
class BasicAuth:
def set_auth_headers(self):
self.set_status(401)

View File

@ -155,7 +155,7 @@ def dummy_cert(privkey, cacert, commonname, sans):
# return current.value
class CertStoreEntry():
class CertStoreEntry:
def __init__(self, cert, privatekey, chain_file):
self.cert = cert
@ -163,7 +163,7 @@ class CertStoreEntry():
self.chain_file = chain_file
class CertStore():
class CertStore:
"""
Implements an in-memory certificate store.

View File

@ -16,7 +16,7 @@ class NetlibException(Exception):
super(NetlibException, self).__init__(message)
class Disconnect():
class Disconnect:
"""Immediate EOF"""

View File

@ -23,7 +23,7 @@ def assemble_http_basic_auth(scheme, username, password):
return scheme + " " + v
class NullProxyAuth():
class NullProxyAuth:
"""
No proxy auth at all (returns empty challange headers)
@ -90,7 +90,7 @@ class BasicProxyAuth(BasicAuth):
AUTH_HEADER = 'Proxy-Authorization'
class PassMan():
class PassMan:
def test(self, username_, password_token_):
return False

View File

@ -283,7 +283,7 @@ class Message(basetypes.Serializable):
self.content = body
class decoded():
class decoded:
"""
Deprecated: You can now directly use :py:attr:`content`.
:py:attr:`raw_content` has the encoded content.

View File

@ -52,7 +52,7 @@ USERNAME_PASSWORD_VERSION = utils.BiDi(
)
class ClientGreeting():
class ClientGreeting:
__slots__ = ("ver", "methods")
def __init__(self, ver, methods):
@ -89,7 +89,7 @@ class ClientGreeting():
f.write(self.methods.tostring())
class ServerGreeting():
class ServerGreeting:
__slots__ = ("ver", "method")
def __init__(self, ver, method):
@ -117,7 +117,7 @@ class ServerGreeting():
f.write(struct.pack("!BB", self.ver, self.method))
class UsernamePasswordAuth():
class UsernamePasswordAuth:
__slots__ = ("ver", "username", "password")
def __init__(self, ver, username, password):
@ -147,7 +147,7 @@ class UsernamePasswordAuth():
f.write(self.password.encode())
class UsernamePasswordAuthResponse():
class UsernamePasswordAuthResponse:
__slots__ = ("ver", "status")
def __init__(self, ver, status):
@ -170,7 +170,7 @@ class UsernamePasswordAuthResponse():
f.write(struct.pack("!BB", self.ver, self.status))
class Message():
class Message:
__slots__ = ("ver", "msg", "atyp", "addr")
def __init__(self, ver, msg, atyp, addr):

View File

@ -72,7 +72,7 @@ sslversion_choices = {
}
class SSLKeyLogger():
class SSLKeyLogger:
def __init__(self, filename):
self.filename = filename
@ -111,7 +111,7 @@ log_ssl_key = SSLKeyLogger.create_logfun(
os.getenv("MITMPROXY_SSLKEYLOGFILE") or os.getenv("SSLKEYLOGFILE"))
class _FileLike():
class _FileLike:
BLOCKSIZE = 1024 * 32
def __init__(self, o):
@ -426,7 +426,7 @@ def close_socket(sock):
sock.close()
class _Connection():
class _Connection:
rbufsize = -1
wbufsize = -1
@ -574,7 +574,7 @@ class _Connection():
return context
class ConnectionCloser():
class ConnectionCloser:
def __init__(self, conn):
self.conn = conn
self._canceled = False
@ -888,7 +888,7 @@ class Counter:
self._count -= 1
class TCPServer():
class TCPServer:
request_queue_size = 20
def __init__(self, address):

View File

@ -72,7 +72,7 @@ def raises(expected_exception, obj=None, *args, **kwargs):
raise AssertionError("No exception raised. Return value: {}".format(ret))
class RaisesContext():
class RaisesContext:
def __init__(self, expected_exception):
self.expected_exception = expected_exception

View File

@ -20,7 +20,7 @@ def getbit(byte, offset):
return bool(byte & mask)
class BiDi():
class BiDi:
"""
A wee utility class for keeping bi-directional mappings, like field
@ -49,7 +49,7 @@ class BiDi():
return self.values.get(n, default)
class Data():
class Data:
def __init__(self, name):
m = importlib.import_module(name)

View File

@ -43,7 +43,7 @@ CLOSE_REASON = utils.BiDi(
)
class FrameHeader():
class FrameHeader:
def __init__(
self,
@ -193,7 +193,7 @@ class FrameHeader():
return False
class Frame():
class Frame:
"""
Represents a single WebSockets frame.
Constructor takes human readable forms of the frame components.

View File

@ -1,7 +1,7 @@
from __future__ import absolute_import
class Masker():
class Masker:
"""
Data sent from the server must be masked to prevent malicious clients
from sending data over the wire in predictable patterns.

View File

@ -8,20 +8,20 @@ import io
from netlib import http, tcp, strutils
class ClientConn():
class ClientConn:
def __init__(self, address):
self.address = tcp.Address.wrap(address)
class Flow():
class Flow:
def __init__(self, address, request):
self.client_conn = ClientConn(address)
self.request = request
class Request():
class Request:
def __init__(self, scheme, method, path, http_version, headers, content):
self.scheme, self.method, self.path = scheme, method, path
@ -47,7 +47,7 @@ def date_time_string():
return s
class WSGIAdaptor():
class WSGIAdaptor:
def __init__(self, app, domain, port, sversion):
self.app, self.domain, self.port, self.sversion = app, domain, port, sversion

View File

@ -10,7 +10,7 @@ from netlib import human
from . import generators, exceptions
class Settings():
class Settings:
def __init__(
self,
@ -60,7 +60,7 @@ v_naked_literal = pp.MatchFirst(
)
class Token():
class Token:
"""
A token in the specification language. Tokens are immutable. The token

View File

@ -18,7 +18,7 @@ DATATYPES = dict(
)
class TransformGenerator():
class TransformGenerator:
"""
Perform a byte-by-byte transform another generator - that is, for each
@ -54,7 +54,7 @@ def rand_byte(chars):
return bytes([random.choice(chars)])
class RandomGenerator():
class RandomGenerator:
def __init__(self, dtype, length):
self.dtype = dtype
@ -73,7 +73,7 @@ class RandomGenerator():
return "%s random from %s" % (self.length, self.dtype)
class FileGenerator():
class FileGenerator:
def __init__(self, path):
self.path = path

View File

@ -53,7 +53,7 @@ class Method(base.OptionsOrValue):
]
class _HeaderMixin():
class _HeaderMixin:
unique_name = None
def format_header(self, key, value):

View File

@ -40,7 +40,7 @@ def get_header(val, headers):
return None
class _HeaderMixin():
class _HeaderMixin:
unique_name = None
def values(self, settings):

View File

@ -5,7 +5,7 @@ from netlib import strutils
LOG_TRUNCATE = 1024
class Message():
class Message:
__metaclass__ = abc.ABCMeta
logattrs = []

View File

@ -13,7 +13,7 @@ def write_raw(fp, lines, timestamp=True):
fp.flush()
class LogCtx():
class LogCtx:
def __init__(self, fp, hex, timestamp, rfile, wfile):
self.lines = []

View File

@ -34,7 +34,7 @@ class PathocError(Exception):
pass
class SSLInfo():
class SSLInfo:
def __init__(self, certchain, cipher, alp):
self.certchain, self.cipher, self.alp = certchain, cipher, alp

View File

@ -30,7 +30,7 @@ class PathodError(Exception):
pass
class SSLOptions():
class SSLOptions:
def __init__(
self,
confdir=CONFDIR,

View File

@ -4,7 +4,7 @@ from netlib.http import http1
from .. import language
class HTTPProtocol():
class HTTPProtocol:
def __init__(self, pathod_handler):
self.pathod_handler = pathod_handler

View File

@ -15,14 +15,14 @@ import netlib.http.request
from .. import language
class TCPHandler():
class TCPHandler:
def __init__(self, rfile, wfile=None):
self.rfile = rfile
self.wfile = wfile
class HTTP2StateProtocol():
class HTTP2StateProtocol:
ERROR_CODES = utils.BiDi(
NO_ERROR=0x0,
@ -403,7 +403,7 @@ class HTTP2StateProtocol():
return stream_id, headers, body
class HTTP2Protocol():
class HTTP2Protocol:
def __init__(self, pathod_handler):
self.pathod_handler = pathod_handler

View File

@ -3,7 +3,7 @@ import sys
import netlib.utils
class MemBool():
class MemBool:
"""
Truth-checking with a memory, for use in chained if statements.

View File

@ -51,7 +51,7 @@ class TestPathCompleter:
assert c.final == s
class TestPathEdit():
class TestPathEdit:
def test_keypress(self):

View File

@ -6,7 +6,7 @@ from netlib.tutils import treq
from .. import tutils, tservers
class TestHTTPFlow():
class TestHTTPFlow:
def test_repr(self):
f = tutils.tflow(resp=True, err=True)

View File

@ -89,7 +89,7 @@ class _Http2ServerBase(netlib_tservers.ServerTestBase):
raise NotImplementedError()
class _Http2TestBase():
class _Http2TestBase:
@classmethod
def setup_class(cls):

View File

@ -44,7 +44,7 @@ class _WebSocketsServerBase(netlib_tservers.ServerTestBase):
traceback.print_exc()
class _WebSocketsTestBase():
class _WebSocketsTestBase:
@classmethod
def setup_class(cls):

View File

@ -15,7 +15,7 @@ class TMsg:
pass
class TestMaster():
class TestMaster:
def test_simple(self):
class DummyMaster(controller.Master):
@controller.handler
@ -44,7 +44,7 @@ class TestMaster():
m.shutdown()
class TestServerThread():
class TestServerThread:
def test_simple(self):
m = Mock()
t = controller.ServerThread(m)
@ -52,7 +52,7 @@ class TestServerThread():
assert m.serve_forever.called
class TestChannel():
class TestChannel:
def test_tell(self):
q = queue.Queue()
channel = controller.Channel(q, Event())
@ -86,7 +86,7 @@ class TestChannel():
channel.ask("test", Mock(name="test_ask_shutdown"))
class TestReply():
class TestReply:
def test_simple(self):
reply = controller.Reply(42)
assert reply.state == "unhandled"
@ -179,7 +179,7 @@ class TestReply():
reply.commit()
class TestDummyReply():
class TestDummyReply:
def test_simple(self):
reply = controller.DummyReply()
for _ in range(2):

View File

@ -99,7 +99,7 @@ class TestScripts(mastertest.MasterTest):
assert f.request.host == "mitmproxy.org"
class TestHARDump():
class TestHARDump:
def flow(self, resp_content=b'message'):
times = dict(

View File

@ -37,7 +37,7 @@ def test_app_registry():
assert ar.get(r)
class TestHTTPFlow():
class TestHTTPFlow:
def test_copy(self):
f = tutils.tflow(resp=True)

View File

@ -31,7 +31,7 @@ def req_patch():
return netlib.tutils.treq(method=b'PATCH', path=b"/path?query=param")
class TestExportCurlCommand():
class TestExportCurlCommand:
def test_get(self):
flow = tutils.tflow(req=req_get())
result = """curl -H 'header:qvalue' -H 'content-length:7' 'http://address/path?a=foo&a=bar&b=baz'"""
@ -48,7 +48,7 @@ class TestExportCurlCommand():
assert export.curl_command(flow) == result
class TestExportPythonCode():
class TestExportPythonCode:
def test_get(self):
flow = tutils.tflow(req=req_get())
python_equals("data/test_flow_export/python_get.py", export.python_code(flow))
@ -69,7 +69,7 @@ class TestExportPythonCode():
python_equals("data/test_flow_export/python_patch.py", export.python_code(flow))
class TestExportLocustCode():
class TestExportLocustCode:
def test_get(self):
flow = tutils.tflow(req=req_get())
python_equals("data/test_flow_export/locust_get.py", export.locust_code(flow))
@ -86,7 +86,7 @@ class TestExportLocustCode():
python_equals("data/test_flow_export/locust_patch.py", export.locust_code(flow))
class TestExportLocustTask():
class TestExportLocustTask:
def test_get(self):
flow = tutils.tflow(req=req_get())
python_equals("data/test_flow_export/locust_task_get.py", export.locust_task(flow))
@ -100,7 +100,7 @@ class TestExportLocustTask():
python_equals("data/test_flow_export/locust_task_patch.py", export.locust_task(flow))
class TestIsJson():
class TestIsJson:
def test_empty(self):
assert export.is_json(None, None) is False
@ -119,7 +119,7 @@ class TestIsJson():
assert isinstance(j, dict)
class TestURL():
class TestURL:
def test_url(self):
flow = tutils.tflow()
assert export.url(flow) == "http://address:22/path"

View File

@ -14,7 +14,7 @@ from netlib.http import http1
from . import tutils
class TestServerConnection():
class TestServerConnection:
def test_simple(self):
self.d = test.Daemon()

View File

@ -74,7 +74,7 @@ class ProxyThread(threading.Thread):
self.tmaster.shutdown()
class ProxyTestBase():
class ProxyTestBase:
# Test Configuration
ssl = None
ssloptions = False

View File

@ -104,7 +104,7 @@ def test_read_response_head():
assert rfile.read() == b"skip"
class TestReadBody():
class TestReadBody:
def test_chunked(self):
rfile = BytesIO(b"3\r\nfoo\r\n0\r\n\r\nbar")
body = b"".join(read_body(rfile, None))
@ -289,7 +289,7 @@ def test_check_http_version():
_check_http_version(b"HTTP/1.b")
class TestReadHeaders():
class TestReadHeaders:
@staticmethod
def _read(data):
return _read_headers(BytesIO(data))

View File

@ -4,7 +4,7 @@ from netlib.http.headers import Headers, parse_content_type, assemble_content_ty
from netlib.tutils import raises
class TestHeaders():
class TestHeaders:
def _2host(self):
return Headers(
(

View File

@ -36,7 +36,7 @@ def _test_decoded_attr(message, attr):
assert getattr(message.data, attr) == b"FOO\xBF\x00BAR"
class TestMessageData():
class TestMessageData:
def test_eq_ne(self):
data = tresp(timestamp_start=42, timestamp_end=42).data
same = tresp(timestamp_start=42, timestamp_end=42).data
@ -50,7 +50,7 @@ class TestMessageData():
assert data != 0
class TestMessage():
class TestMessage:
def test_init(self):
resp = tresp()
@ -108,7 +108,7 @@ class TestMessage():
assert r.content == b"ggfootoo"
class TestMessageContentEncoding():
class TestMessageContentEncoding:
def test_simple(self):
r = tresp()
assert r.raw_content == b"message"
@ -186,7 +186,7 @@ class TestMessageContentEncoding():
assert "content-encoding" not in r.headers
class TestMessageText():
class TestMessageText:
def test_simple(self):
r = tresp(content=b'\xfc')
assert r.raw_content == b"\xfc"

View File

@ -6,7 +6,7 @@ from netlib.tutils import treq, raises
from .test_message import _test_decoded_attr, _test_passthrough_attr
class TestRequestData():
class TestRequestData:
def test_init(self):
with raises(ValueError):
treq(headers="foobar")
@ -14,7 +14,7 @@ class TestRequestData():
assert isinstance(treq(headers=()).headers, Headers)
class TestRequestCore():
class TestRequestCore:
"""
Tests for builtins and the attributes that are directly proxied from the data structure
"""
@ -92,7 +92,7 @@ class TestRequestCore():
assert request.headers["Host"] == "example.org"
class TestRequestUtils():
class TestRequestUtils:
"""
Tests for additional convenience methods.
"""

View File

@ -11,7 +11,7 @@ from netlib.tutils import raises, tresp
from .test_message import _test_passthrough_attr, _test_decoded_attr
class TestResponseData():
class TestResponseData:
def test_init(self):
with raises(ValueError):
tresp(headers="foobar")
@ -19,7 +19,7 @@ class TestResponseData():
assert isinstance(tresp(headers=()).headers, Headers)
class TestResponseCore():
class TestResponseCore:
"""
Tests for builtins and the attributes that are directly proxied from the data structure
"""
@ -60,7 +60,7 @@ class TestResponseCore():
_test_decoded_attr(tresp(), "reason")
class TestResponseUtils():
class TestResponseUtils:
"""
Tests for additional convenience methods.
"""

View File

@ -2,7 +2,7 @@ from netlib import tutils
from netlib.multidict import MultiDict, ImmutableMultiDict, MultiDictView
class _TMulti():
class _TMulti:
@staticmethod
def _kconv(key):
return key.lower()
@ -16,7 +16,7 @@ class TImmutableMultiDict(_TMulti, ImmutableMultiDict):
pass
class TestMultiDict():
class TestMultiDict:
@staticmethod
def _multi():
return TMultiDict((
@ -194,7 +194,7 @@ class TestMultiDict():
assert md == md2
class TestImmutableMultiDict():
class TestImmutableMultiDict:
def test_modify(self):
md = TImmutableMultiDict()
with tutils.raises(TypeError):
@ -224,7 +224,7 @@ class TestImmutableMultiDict():
assert md.with_insert(0, "foo", "bar").fields == (("foo", "bar"),)
class TParent():
class TParent:
def __init__(self):
self.vals = tuple()
@ -235,7 +235,7 @@ class TParent():
return self.vals
class TestMultiDictView():
class TestMultiDictView:
def test_modify(self):
p = TParent()
tv = MultiDictView(p.getter, p.setter)

View File

@ -85,7 +85,7 @@ class _TServer(tcp.TCPServer):
self.q.put(s.getvalue())
class ServerTestBase():
class ServerTestBase:
ssl = None
handler = None
addr = ("localhost", 0)

View File

@ -6,7 +6,7 @@ from netlib import websockets
from netlib import tutils
class TestFrameHeader():
class TestFrameHeader:
@pytest.mark.parametrize("input,expected", [
(0, '0100'),
@ -123,7 +123,7 @@ class TestFrameHeader():
assert f.masking_key
class TestFrame():
class TestFrame:
def test_equality(self):
f = websockets.Frame(payload=b'1234')
f2 = websockets.Frame(payload=b'1234')

View File

@ -4,7 +4,7 @@ import pytest
from netlib import websockets
class TestMasker():
class TestMasker:
@pytest.mark.parametrize("input,expected", [
([b"a"], '00'),

View File

@ -4,7 +4,7 @@ from netlib import http
from netlib import websockets
class TestUtils():
class TestUtils:
def test_client_handshake_headers(self):
h = websockets.client_handshake_headers(version='42')

View File

@ -343,7 +343,7 @@ def test_unique_name():
assert b.unique_name
class test_boolean():
class test_boolean:
e = TBoolean.expr()
assert e.parseString("test")[0].value
assert not e.parseString("-test")[0].value

View File

@ -7,7 +7,7 @@ from netlib.exceptions import HttpException, TlsException
from . import tutils
class TestPathod():
class TestPathod:
def test_logging(self):
s = io.StringIO()

View File

@ -169,7 +169,7 @@ class TestPerformClientConnectionPreface(netlib_tservers.ServerTestBase):
assert protocol.connection_preface_performed
class TestClientStreamIds():
class TestClientStreamIds:
c = tcp.TCPClient(("127.0.0.1", 0))
protocol = HTTP2StateProtocol(c)
@ -183,7 +183,7 @@ class TestClientStreamIds():
assert self.protocol.current_stream_id == 5
class TestserverstreamIds():
class TestserverstreamIds:
c = tcp.TCPClient(("127.0.0.1", 0))
protocol = HTTP2StateProtocol(c, is_server=True)
@ -230,7 +230,7 @@ class TestApplySettings(netlib_tservers.ServerTestBase):
hyperframe.frame.SettingsFrame.INITIAL_WINDOW_SIZE] == 'deadbeef'
class TestCreateHeaders():
class TestCreateHeaders:
c = tcp.TCPClient(("127.0.0.1", 0))
def test_create_headers(self):
@ -267,7 +267,7 @@ class TestCreateHeaders():
assert bytes[2] == codecs.decode('00000209040000000163d5', 'hex_codec')
class TestCreateBody():
class TestCreateBody:
c = tcp.TCPClient(("127.0.0.1", 0))
def test_create_body_empty(self):
@ -422,7 +422,7 @@ class TestReadEmptyResponse(netlib_tservers.ServerTestBase):
assert resp.content == b''
class TestAssembleRequest():
class TestAssembleRequest:
c = tcp.TCPClient(("127.0.0.1", 0))
def test_request_simple(self):
@ -476,7 +476,7 @@ class TestAssembleRequest():
codecs.decode('000006000100000001666f6f626172', 'hex_codec')
class TestAssembleResponse():
class TestAssembleResponse:
c = tcp.TCPClient(("127.0.0.1", 0))
def test_simple(self):

View File

@ -23,7 +23,7 @@ def treader(bytes):
return tcp.Reader(fp)
class DaemonTests():
class DaemonTests:
nohang = False
ssl = False
timeout = None