This commit is contained in:
Maximilian Hils 2021-08-23 21:35:31 +02:00 committed by GitHub
parent a6f673fb29
commit 550e1a4ab3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View File

@ -1,4 +1,3 @@
import asyncio
from dataclasses import dataclass from dataclasses import dataclass
from mitmproxy import hooks from mitmproxy import hooks
@ -61,7 +60,7 @@ class Log:
self(txt, "error") self(txt, "error")
def __call__(self, text, level="info"): def __call__(self, text, level="info"):
asyncio.get_event_loop().call_soon( self.master.event_loop.call_soon_threadsafe(
self.master.addons.trigger, AddLogHook(LogEntry(text, level)), self.master.addons.trigger, AddLogHook(LogEntry(text, level)),
) )

View File

@ -40,13 +40,13 @@ class TestCommandHistory:
def test_add_command(self): def test_add_command(self):
ch = command_history.CommandHistory() ch = command_history.CommandHistory()
with taddons.context(ch):
ch.add_command('cmd1')
ch.add_command('cmd2')
assert ch.history == ['cmd1', 'cmd2']
ch.add_command('cmd1') ch.add_command('')
ch.add_command('cmd2') assert ch.history == ['cmd1', 'cmd2']
assert ch.history == ['cmd1', 'cmd2']
ch.add_command('')
assert ch.history == ['cmd1', 'cmd2']
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_add_command_failed(self): async def test_add_command_failed(self):