• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tutils.tmpdir函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_read

    def test_read(self):
        with tutils.tmpdir() as t:
            p = os.path.join(t, "read")
            self._flowfile(p)
            assert "GET" in self._dummy_cycle(0, None, "", verbosity=1, rfile=p)

            libpry.raises(dump.DumpError, self._dummy_cycle, 0, None, "", verbosity=1, rfile="/nonexistent")

            # We now just ignore errors
            self._dummy_cycle(0, None, "", verbosity=1, rfile=tutils.test_data.path("test_dump.py"))
开发者ID:npk,项目名称:mitmproxy,代码行数:10,代码来源:test_dump.py


示例17: test_with_ca

 def test_with_ca(self):
     with tutils.tmpdir() as d:
         cacert = os.path.join(d, "cacert")
         assert certutils.dummy_ca(cacert)
         r = certutils.dummy_cert(
             cacert,
             "foo.com",
             ["one.com", "two.com", "*.three.com"]
         )
         assert r.cn == "foo.com"
开发者ID:blindkey,项目名称:netlib,代码行数:10,代码来源:test_certutils.py


示例18: test_with_ca

 def test_with_ca(self):
     with tutils.tmpdir() as d:
         ca = certutils.CertStore.from_store(d, "test")
         r = certutils.dummy_cert(
             ca.default_privatekey,
             ca.default_ca,
             "foo.com",
             ["one.com", "two.com", "*.three.com"]
         )
         assert r.cn == "foo.com"
开发者ID:grizzer,项目名称:kali-nethunter,代码行数:10,代码来源:test_certutils.py


示例19: test_dummy_ca

def test_dummy_ca():
    with tutils.tmpdir() as d:
        path = os.path.join(d, "foo/cert.cnf")
        assert certutils.dummy_ca(path)
        assert os.path.exists(path)

        path = os.path.join(d, "foo/cert2.pem")
        assert certutils.dummy_ca(path)
        assert os.path.exists(path)
        assert os.path.exists(os.path.join(d, "foo/cert2-cert.pem"))
        assert os.path.exists(os.path.join(d, "foo/cert2-cert.p12"))
开发者ID:a2800276,项目名称:netlib,代码行数:11,代码来源:test_certutils.py


示例20: test_filegenerator

 def test_filegenerator(self):
     with tutils.tmpdir() as t:
         path = os.path.join(t, "foo")
         f = open(path, "w")
         f.write("x"*10000)
         f.close()
         g = rparse.FileGenerator(path)
         assert len(g) == 10000
         assert g[0] == "x"
         assert g[-1] == "x"
         assert g[0:5] == "xxxxx"
         assert repr(g)
开发者ID:emidln,项目名称:pathod,代码行数:12,代码来源:test_rparse.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tutils.treq函数代码示例发布时间:2022-05-27
下一篇:
Python tutils.tflow_full函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap