草庐IT

test_ssl

全部标签

python :unit test throws <Response streamed [200 OK]> instead of actual output

fromflaskimportjsonify@app.route('/urlinfo/1/',methods=['GET'])defsearch(URL):ifsomething:a=dict(message="everythingisgood"resp=jsonify(a)returnrespelse:a=dict(error="problem")returnjsonify(a)我正在使用curl它curlhttp://127.0.0.1:5000/urlinfo/1/'https://www.youtube.com/'它以json格式返回所需的输出。我为它写了一个单元测试impor

python - 导入错误 : cannot import name 'transfer_markers' when testing with pytest

当我通过运行以下命令为我的python项目运行测试时:pythonsetup.pytest(or)pytestproject_name我收到以下错误:.../project_name/.eggs/pytest_asyncio-0.9.0-py3.6.egg/pytest_asyncio/plugin.py",line8,infrom_pytest.pythonimporttransfer_markersImportError:cannotimportname'transfer_markers' 最佳答案 当我在网上查找时,几乎没有任

Python 列表理解 : test function return

有没有办法在列表(或字典)理解中测试函数的返回?我想避免这样写:lst=[]forxinrange(10):bar=foo(x)ifbar:lst.append(bar)并改用列表理解。显然,我不想写:[foo(x)forxinrange(10)iffoo(x)]所以呢?[foo(x)forxinrange(10)if???] 最佳答案 怎么样filter(None,map(foo,range(10)))如果您不想保留中间列表,请将map()替换为itertools.imap().和itertools.ifilter(),整个东西可

python - 旧 python 版本的 SSL 上下文

我有如下代码:headers={'content-type':'ContentType.APPLICATION_XML'}uri="www.client.url.com/hit-here/"clientCert="path/to/cert/abc.crt"clientKey="path/to/key/abc.key"PROTOCOL=ssl.PROTOCOL_TLSv1context=ssl.SSLContext(PROTOCOL)context.load_default_certs()context.load_cert_chain(clientCert,clientKey)conn=

python - py.test : specifying python_files in the command line

我想在pytest中设置参数python_files。文档说你需要把它放在一个配置文件中,但我想把它作为调用py.test的一部分包含在命令行中,所以我不必添加那个配置文件。这可能吗? 最佳答案 不可能像现在(2.8)那样开箱即用的pytest。pytestparser了解命令行选项(addoption/getoption)和配置文件值(addini/getini),但它们完全不同。可能可以编写一个插件来添加python_files(或任何其他ini值)作为命令行选项。但只添加一个conftest文件肯定是更简单的选择。

python - 运行 py.test 时的 .coveragerc 文件位置

我正在尝试让pytest运行以处理coveragerc文件。我的.coveragerc文件中的设置没有被使用,所以我猜这个文件根本没有被使用。在下面查看我的项目结构和pytest调用!我做错了什么?项目:basepath/lib/basepath/.coveragercbasepath/test/test_libbasepath/test/run.py我从virtualenv调用test/run.pybasepath$pythontest/run.py运行.pyimportpytestpytest.main('test/test_lib-v--cov-reportxml--covlib

python - 在 Lubuntu 14.04 上安装 Python3.4.3 时出现错误/测试失败

我使用VMplayer,我的操作系统是Lubuntu14.04。它预装了python3.4.0,但我想安装python3.4.3。我从here下载了.tar.xz文件.然后我提取文件并按照自述文件中的说明进行操作:./configuremakemaketest当我第一次运行时maketest它说“3次测试失败,3次更改执行环境,25次跳过”。我在这里发布了关于SO的问题:InstallingPython3.4.3:3testsfailed,3alteredexecutionenvironmentand25skipped然后我做了sudoapt-getinstalllibssl-dev做

解决客户端和服务器不支持一般SSL协议版本或加密套件问题

错误信息详细报错信息如下图错误原因这种错误通常表示客户端和服务器之间存在协议版本或加密套件不匹配的情况。在SSL(SecureSocketLayer)连接过程中,客户端和服务器需要协商一种相同的加密协议版本和加密套件,以确保数据的安全传输。具体可能出现的原因包括:1.协议版本不兼容:客户端和服务器可能支持不同版本的SSL协议,导致协议版本不匹配。2.加密套件不匹配:客户端和服务器可能支持不同的加密套件,导致加密套件不匹配。例如,如果客户端只支持使用AES加密算法,而服务器只支持使用RC4加密算法,则它们无法协商一种相同的加密套件。3.协议配置不正确:客户端和服务器的SSL协议配置可能不正确,例

python - 在 mechanize 中禁用 ssl 证书验证

我是python的新手,我正在尝试使用mechanize访问网站。br=mechanize.Browser()r=br.open("https://172.22.2.2/")这给了我以下错误:Traceback(mostrecentcalllast):File"",line1,inbr.open("https://172.22.2.2/")File"/home/freeza/.local/lib/python2.7/site-packages/mechanize/_mechanize.py",line203,inopenreturnself._mech_open(url,data,ti

Python ssl 服务器报告 TLSV1_ALERT_UNKNOWN_CA

我有一个使用自签名证书的PythonSSL服务器。我这样启动我的服务器:httpd=BaseHTTPServer.HTTPServer(('',443),MyHTTPHandler)httpd.socket=ssl.wrap_socket(httpd.socket,certfile='server.pem',server_side=True,cert_reqs=0)httpd.serve_forever()当我使用Firefox连接时出现以下错误:----------------------------------------Exceptionhappenedduringprocess