diff options
author | Maximilian Hils <git@maximilianhils.com> | 2017-07-20 16:00:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-20 16:00:58 +0200 |
commit | 8b0b4c42b05446301b18f199d7eac0819b1d52fb (patch) | |
tree | afa724e2ec441f80432240016f6d1522616915fb /test | |
parent | 374c27feb64b0215a7e94cb9f30c27c84bcc437b (diff) | |
parent | 94d28831e1bc3d8d4ddcdf858a40921913b75406 (diff) | |
download | mitmproxy-8b0b4c42b05446301b18f199d7eac0819b1d52fb.tar.gz mitmproxy-8b0b4c42b05446301b18f199d7eac0819b1d52fb.tar.bz2 mitmproxy-8b0b4c42b05446301b18f199d7eac0819b1d52fb.zip |
Merge pull request #2455 from mhils/script-fixes
Fix loading scripts with same filename
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/addons/test_script.py | 24 | ||||
-rw-r--r-- | test/mitmproxy/data/addonscripts/same_filename/addon.py | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/test/mitmproxy/addons/test_script.py b/test/mitmproxy/addons/test_script.py index 03b1f620..b7e6c82a 100644 --- a/test/mitmproxy/addons/test_script.py +++ b/test/mitmproxy/addons/test_script.py @@ -30,6 +30,30 @@ def test_load_script(): assert not ns +def test_load_fullname(): + """ + Test that loading two scripts at locations a/foo.py and b/foo.py works. + This only succeeds if they get assigned different basenames. + + """ + with taddons.context() as tctx: + ns = script.load_script( + tctx.ctx(), + tutils.test_data.path( + "mitmproxy/data/addonscripts/addon.py" + ) + ) + assert ns.addons + ns2 = script.load_script( + tctx.ctx(), + tutils.test_data.path( + "mitmproxy/data/addonscripts/same_filename/addon.py" + ) + ) + assert ns.name != ns2.name + assert not hasattr(ns2, "addons") + + def test_script_print_stdout(): with taddons.context() as tctx: with mock.patch('mitmproxy.ctx.log.warn') as mock_warn: diff --git a/test/mitmproxy/data/addonscripts/same_filename/addon.py b/test/mitmproxy/data/addonscripts/same_filename/addon.py new file mode 100644 index 00000000..c84a9b13 --- /dev/null +++ b/test/mitmproxy/data/addonscripts/same_filename/addon.py @@ -0,0 +1 @@ +foo = 42 |