aboutsummaryrefslogtreecommitdiffstats
path: root/test/mitmproxy/tools/console/test_commander.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/mitmproxy/tools/console/test_commander.py')
-rw-r--r--test/mitmproxy/tools/console/test_commander.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/test/mitmproxy/tools/console/test_commander.py b/test/mitmproxy/tools/console/test_commander.py
index 06e676c0..4fa10eb8 100644
--- a/test/mitmproxy/tools/console/test_commander.py
+++ b/test/mitmproxy/tools/console/test_commander.py
@@ -1,7 +1,4 @@
-import os
import pytest
-import shutil
-import uuid
from mitmproxy import options
from mitmproxy.addons import command_history
@@ -10,24 +7,22 @@ from mitmproxy.tools.console.commander import commander
@pytest.fixture(autouse=True)
-def tctx():
+def tctx(tmpdir):
# This runs before each test
- dir_id = str(uuid.uuid4())
- confdir = os.path.expanduser(f"~/.mitmproxy-test-suite-{dir_id}")
- if not os.path.exists(confdir):
- os.makedirs(confdir)
+ dir_name = tmpdir.mkdir('mitmproxy').dirname
+ confdir = dir_name
opts = options.Options()
opts.set(*[f"confdir={confdir}"])
tctx = taddons.context(options=opts)
ch = command_history.CommandHistory()
tctx.master.addons.add(ch)
+ ch.configure([])
yield tctx
# This runs after each test
- ch.command_history_file.close()
- shutil.rmtree(confdir)
+ ch.cleanup()
class TestListCompleter: