aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2018-04-26 21:02:10 +1200
committerGitHub <noreply@github.com>2018-04-26 21:02:10 +1200
commita4a48a96d6cfb0e423a301a07200eee2c7796ce1 (patch)
tree9ff0303433363c0334670713cf418b5138cf3d43 /test
parent13f3cbed4feb3b1a248ee6120446ada0330e9e76 (diff)
parenta42443b029f1fa4a654b5a0e44b71026c6f1415b (diff)
downloadmitmproxy-a4a48a96d6cfb0e423a301a07200eee2c7796ce1.tar.gz
mitmproxy-a4a48a96d6cfb0e423a301a07200eee2c7796ce1.tar.bz2
mitmproxy-a4a48a96d6cfb0e423a301a07200eee2c7796ce1.zip
Merge pull request #3078 from kajojify/expanduser
Fix #3002. Auto-expanding for tilda.
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_types.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/mitmproxy/test_types.py b/test/mitmproxy/test_types.py
index b4a643ad..35ff3241 100644
--- a/test/mitmproxy/test_types.py
+++ b/test/mitmproxy/test_types.py
@@ -2,6 +2,7 @@ import pytest
import os
import typing
import contextlib
+from unittest import mock
import mitmproxy.exceptions
import mitmproxy.types
@@ -68,7 +69,10 @@ def test_path(tdata):
b = mitmproxy.types._PathType()
assert b.parse(tctx.master.commands, mitmproxy.types.Path, "/foo") == "/foo"
assert b.parse(tctx.master.commands, mitmproxy.types.Path, "/bar") == "/bar"
+ with mock.patch.dict("os.environ", {"HOME": "/home/test"}):
+ assert b.parse(tctx.master.commands, mitmproxy.types.Path, "~/mitm") == "/home/test/mitm"
assert b.is_valid(tctx.master.commands, mitmproxy.types.Path, "foo") is True
+ assert b.is_valid(tctx.master.commands, mitmproxy.types.Path, "~/mitm") is True
assert b.is_valid(tctx.master.commands, mitmproxy.types.Path, 3) is False
def normPathOpts(prefix, match):