当前位置: 首页>>代码示例>>Python>>正文


Python tutils.tmpdir函数代码示例

本文整理汇总了Python中tutils.tmpdir函数的典型用法代码示例。如果您正苦于以下问题:Python tmpdir函数的具体用法?Python tmpdir怎么用?Python tmpdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了tmpdir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_stream

    def test_stream(self):
        with tutils.tmpdir() as tdir:
            p = os.path.join(tdir, "foo")

            def r():
                r = flow.FlowReader(open(p, "rb"))
                return list(r.stream())

            s = flow.State()
            fm = flow.FlowMaster(None, s)
            f = tutils.tflow(resp=True)

            fm.start_stream(file(p, "ab"), None)
            fm.handle_request(f)
            fm.handle_response(f)
            fm.stop_stream()

            assert r()[0].response

            f = tutils.tflow()
            fm.start_stream(file(p, "ab"), None)
            fm.handle_request(f)
            fm.shutdown()

            assert not r()[1].response
开发者ID:tracyhatemice,项目名称:mitmproxy,代码行数:25,代码来源:test_flow.py

示例2: test_certs

    def test_certs(self):
        with tutils.tmpdir() as confdir:
            self.assert_noerr("--client-certs", confdir)
            self.assert_err("directory does not exist", "--client-certs", "nonexistent")

            self.assert_noerr("--dummy-certs", confdir)
            self.assert_err("directory does not exist", "--dummy-certs", "nonexistent")
开发者ID:Pballen,项目名称:mitmproxy,代码行数:7,代码来源:test_proxy.py

示例3: handle

 def handle(self):
     with tutils.tmpdir() as d:
         ca1 = certutils.CertStore.from_store(d, "test2")
         ca2 = certutils.CertStore.from_store(d, "test3")
         cert, _ = ca1.get_cert("foo.com", [])
         certffi.set_flags(ca2.privkey, 0)
         self.convert_to_ssl(cert, ca2.privkey)
开发者ID:clonger89,项目名称:netlib,代码行数:7,代码来源:test_tcp.py

示例4: test_access_control

    def test_access_control(self):
        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]
            tutils.raises(
                exceptions.FileAccessDenied,
                v.get_generator,
                language.Settings(staticdir=t)
            )
            tutils.raises(
                "access disabled",
                v.get_generator,
                language.Settings()
            )

            v = base.TokValue.parseString("</outside")[0]
            tutils.raises(
                "outside",
                v.get_generator,
                language.Settings(staticdir=t)
            )
开发者ID:bemre,项目名称:mitmproxy,代码行数:27,代码来源:test_language_base.py

示例5: test_create_explicit

 def test_create_explicit(self):
     with tutils.tmpdir() as d:
         ca = os.path.join(d, "ca")
         assert certutils.dummy_ca(ca)
         c = certutils.CertStore(d)
         c.cleanup()
         assert os.path.exists(d)
开发者ID:a2800276,项目名称:netlib,代码行数:7,代码来源:test_certutils.py

示例6: test_sans

 def test_sans(self):
     with tutils.tmpdir() as d:
         ca = certutils.CertStore.from_store(d, "test")
         c1 = ca.get_cert("foo.com", ["*.bar.com"])
         ca.get_cert("foo.bar.com", [])
         # assert c1 == c2
         c3 = ca.get_cert("bar.com", [])
         assert not c1 == c3
开发者ID:grizzer,项目名称:kali-nethunter,代码行数:8,代码来源:test_certutils.py

示例7: test_create_tmp

 def test_create_tmp(self):
     with tutils.tmpdir() as d:
         ca = os.path.join(d, "ca")
         assert certutils.dummy_ca(ca)
         c = certutils.CertStore()
         assert c.get_cert("foo.com", [], ca)
         assert c.get_cert("foo.com", [], ca)
         assert c.get_cert("*.foo.com", [], ca)
开发者ID:blindkey,项目名称:netlib,代码行数:8,代码来源:test_certutils.py

示例8: test_cert

 def test_cert(self):
     path = tutils.test_data.path("data/confdir/") + "mitmproxy-ca-cert."
     with tutils.tmpdir() as d:
         for ext in ["pem", "p12"]:
             resp = self.app("/cert/%s" % ext)
             assert resp.status_code == 200
             with open(path + ext, "rb") as f:
                 assert resp.content == f.read()
开发者ID:Bitesher,项目名称:mitmproxy,代码行数:8,代码来源:test_app.py

示例9: test_one

 def test_one(self):
     with tutils.tmpdir() as t:
         old = os.getcwd()
         sub = os.path.join(t, "sub")
         os.mkdir(sub)
         with utils.InDir(sub):
             assert os.getcwd() != old
         assert os.getcwd() == old
开发者ID:alexdong,项目名称:countershape,代码行数:8,代码来源:test_utils.py

示例10: test_create_explicit

    def test_create_explicit(self):
        with tutils.tmpdir() as d:
            ca = certutils.CertStore.from_store(d, "test")
            assert ca.get_cert("foo", [])

            ca2 = certutils.CertStore.from_store(d, "test")
            assert ca2.get_cert("foo", [])

            assert ca.default_ca.get_serial_number() == ca2.default_ca.get_serial_number()
开发者ID:BennyH26,项目名称:netlib,代码行数:9,代码来源:test_certutils.py

示例11: test_no_ca

 def test_no_ca(self):
     with tutils.tmpdir() as d:
         p = certutils.dummy_cert(
             d,
             None,
             "foo.com",
             []
         )
         assert os.path.exists(p)
开发者ID:emidln,项目名称:netlib,代码行数:9,代码来源:test_certutils.py

示例12: test_create_tmp

    def test_create_tmp(self):
        with tutils.tmpdir() as d:
            ca = certutils.CertStore.from_store(d, "test")
            assert ca.get_cert("foo.com", [])
            assert ca.get_cert("foo.com", [])
            assert ca.get_cert("*.foo.com", [])

            r = ca.get_cert("*.foo.com", [])
            assert r[1] == ca.default_privatekey
开发者ID:grizzer,项目名称:kali-nethunter,代码行数:9,代码来源:test_certutils.py

示例13: test_gen_pkey

 def test_gen_pkey(self):
     try:
         with tutils.tmpdir() as d:
             ca1 = certutils.CertStore.from_store(os.path.join(d, "ca1"), "test")
             ca2 = certutils.CertStore.from_store(os.path.join(d, "ca2"), "test")
             cert = ca1.get_cert("foo.com", [])
             assert certffi.get_flags(ca2.gen_pkey(cert[0])) == 1
     finally:
         certffi.set_flags(ca2.default_privatekey, 0)
开发者ID:BennyH26,项目名称:netlib,代码行数:9,代码来源:test_certutils.py

示例14: test_render

 def test_render(self):
     with tutils.tmpdir() as t:
         self.application.render(t)
         assert os.path.isfile(os.path.join(t, "test.html"))
         assert os.path.isfile(os.path.join(t, "copy"))
         assert os.path.isfile(os.path.join(t, "copy2"))
         assert os.path.isdir(os.path.join(t, "testmod"))
         assert os.path.isfile(os.path.join(t, "testmod_index.html"))
         assert os.path.isfile(os.path.join(t, "sitemap.xml"))
开发者ID:alexdong,项目名称:countershape,代码行数:9,代码来源:test_doc.py

示例15: test_client_certs

 def test_client_certs(self):
     with tutils.tmpdir() as cadir:
         self.assert_noerr("--client-certs", cadir)
         self.assert_noerr(
             "--client-certs",
             os.path.join(tutils.test_data.path("data/clientcert"), "client.pem"))
         self.assert_err(
             "path does not exist",
             "--client-certs",
             "nonexistent")
开发者ID:Rmohid,项目名称:mitmproxy,代码行数:10,代码来源:test_proxy.py


注:本文中的tutils.tmpdir函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。