diff options
| author | Maximilian Hils <git@maximilianhils.com> | 2017-03-12 23:33:49 +0100 |
|---|---|---|
| committer | Maximilian Hils <git@maximilianhils.com> | 2017-03-12 23:33:49 +0100 |
| commit | 05e11547f5875a4b5b3c109db8a1db477d1986ad (patch) | |
| tree | 5c6c5acb7fedeee2e62fc5266d0d9211421fdfa5 /test/pathod/language/test_base.py | |
| parent | 0f4b523868856fccaf373c9108c9220a3aafb30b (diff) | |
| parent | 7d5ab70ce3a6deb70aa3e30e755fdee0f3b2fdeb (diff) | |
| download | mitmproxy-05e11547f5875a4b5b3c109db8a1db477d1986ad.tar.gz mitmproxy-05e11547f5875a4b5b3c109db8a1db477d1986ad.tar.bz2 mitmproxy-05e11547f5875a4b5b3c109db8a1db477d1986ad.zip | |
Merge remote-tracking branch 'origin/master' into pr-2120
Conflicts:
test/mitmproxy/addons/test_replace.py
Diffstat (limited to 'test/pathod/language/test_base.py')
| -rw-r--r-- | test/pathod/language/test_base.py | 35 |
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] |
