我正在学习pytest,我用pylint把代码搞定了.但是pylint仍抱怨:
W0621: Redefining name %r from outer scope (line %s)
对于pytest的以下示例:
# test_wallet.py
@pytest.fixture
def my_wallet():
'''Returns a Wallet instance with a zero balance'''
return Wallet()
@pytest.mark.parametrize("earned,spent,expected", [
(30, 10, 20),
(20, 2, 18),
])
def test_transactions(my_wallet, earned, spent, expected):
my_wallet.add_cash(earned)
my_wallet.spend_cash(spent)
assert my_wallet.balance == expected
Run Code Online (Sandbox Code Playgroud)
my_wallet从外部范围重新定义名称.
我找到了解决方法,_为夹具名称添加前缀:_my_wallet.
如果我想将灯具保存在与功能相同的文件中,那么最佳做法是什么?
_?pylint检查以进行测试?我可以通过SSL套接字上的getpeercert()方法获取Python 3.3中SSL连接的标准证书信息.但是,它似乎没有像OpenSSL的"s_client"工具那样提供链.
有什么方法我可以得到这个,以便我可以看到我的IA证书是否配置正确?
s_client命令行:
openssl s_client -connect google.com:443
Run Code Online (Sandbox Code Playgroud)
s_client结果(只是前几行):
$ openssl s_client -connect google.com:443
CONNECTED(00000003)
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=*.google.com
i:/C=US/O=Google Inc/CN=Google Internet Authority G2
1 s:/C=US/O=Google Inc/CN=Google Internet Authority G2
i:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
2 s:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
---
Run Code Online (Sandbox Code Playgroud)
Python 3.3代码:
import socket
from ssl import SSLContext # Modern SSL? …Run Code Online (Sandbox Code Playgroud)