aboutsummaryrefslogtreecommitdiffstats
path: root/test/pathod/language/test_base.py
diff options
context:
space:
mode:
authorThomas Kriechbaumer <Kriechi@users.noreply.github.com>2017-03-12 23:27:27 +0100
committerGitHub <noreply@github.com>2017-03-12 23:27:27 +0100
commit7d5ab70ce3a6deb70aa3e30e755fdee0f3b2fdeb (patch)
treee25684ad8daf7d0ab59dc15d7dda40f59f5f066c /test/pathod/language/test_base.py
parentd069ba9da58beb65d8139c728cc20abcb01de3a4 (diff)
parent1b045d24bccd68f6db1e15c655af192cb5217a6a (diff)
downloadmitmproxy-7d5ab70ce3a6deb70aa3e30e755fdee0f3b2fdeb.tar.gz
mitmproxy-7d5ab70ce3a6deb70aa3e30e755fdee0f3b2fdeb.tar.bz2
mitmproxy-7d5ab70ce3a6deb70aa3e30e755fdee0f3b2fdeb.zip
Merge pull request #2136 from Kriechi/nuke-custom-tmpdir
nuke tutils.tmpdir, use pytest tmpdir
Diffstat (limited to 'test/pathod/language/test_base.py')
-rw-r--r--test/pathod/language/test_base.py35
1 files changed, 15 insertions, 20 deletions
diff --git a/test/pathod/language/test_base.py b/test/pathod/language/test_base.py
index 85e9e53b..ec460b07 100644
--- a/test/pathod/language/test_base.py
+++ b/test/pathod/language/test_base.py
@@ -1,11 +1,8 @@
-import os
import pytest
from pathod import language
from pathod.language import base, exceptions
-from mitmproxy.test import tutils
-
def parse_request(s):
return language.parse_pathoc(s).next()
@@ -137,24 +134,22 @@ class TestTokValueFile:
v = base.TokValue.parseString("<path")[0]
assert v.path == "path"
- def test_access_control(self):
+ def test_access_control(self, tmpdir):
v = base.TokValue.parseString("<path")[0]
- with tutils.tmpdir() as t:
- p = os.path.join(t, "path")
- with open(p, "wb") as f:
- f.write(b"x" * 10000)
-
- assert v.get_generator(language.Settings(staticdir=t))
-
- v = base.TokValue.parseString("<path2")[0]
- with pytest.raises(exceptions.FileAccessDenied):
- v.get_generator(language.Settings(staticdir=t))
- with pytest.raises(Exception, match="access disabled"):
- v.get_generator(language.Settings())
-
- v = base.TokValue.parseString("</outside")[0]
- with pytest.raises(Exception, match="outside"):
- v.get_generator(language.Settings(staticdir=t))
+ f = tmpdir.join("path")
+ f.write(b"x" * 10000)
+
+ assert v.get_generator(language.Settings(staticdir=str(tmpdir)))
+
+ v = base.TokValue.parseString("<path2")[0]
+ with pytest.raises(exceptions.FileAccessDenied):
+ v.get_generator(language.Settings(staticdir=str(tmpdir)))
+ with pytest.raises(Exception, match="access disabled"):
+ v.get_generator(language.Settings())
+
+ v = base.TokValue.parseString("</outside")[0]
+ with pytest.raises(Exception, match="outside"):
+ v.get_generator(language.Settings(staticdir=str(tmpdir)))
def test_spec(self):
v = base.TokValue.parseString("<'one two'")[0]