我在Ubuntu 14.04.2 LTS上使用python 2.7.6.我正在使用mock来模拟一些单元测试并注意到当我导入mock时它无法导入换行.
不确定是否有一个不同版本的模拟或六个我应该使用它的导入工作?找不到任何相关答案,我没有使用虚拟环境.
mock模块说它与python 2.7.x兼容:https://pypi.python.org/pypi/mock
mock == 1.1.3 six == 1.9.0
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from mock import Mock
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/mock/__init__.py", line 2, in <module>
import mock.mock as _mock
File "/usr/local/lib/python2.7/dist-packages/mock/mock.py", line 68, in <module>
from six import wraps
ImportError: cannot import name wraps
Run Code Online (Sandbox Code Playgroud)
也试过sudo没有运气.
$ sudo python …Run Code Online (Sandbox Code Playgroud) 如果我声明常量如下,我得到错误'os.Getenv中的const初始化器("MY_SECRET")不是常量'.为什么是这样?
Go的新手,我看到Getenv的返回类型是一个字符串,但我不明白为什么这不会作为一个常量.
const (
secret = os.Getenv("MY_SECRET")
key = os.Getenv("MY_KEY")
)
Run Code Online (Sandbox Code Playgroud) 我想知道是否有人知道在 OSX 中管理 USB 串行端口名称的方法?例如,每当我连接特定的设备序列号时,我总是希望它是序列号 /dev/device1
我知道在 linux 中你可以通过 /etc/udev/rules.d/49-persistent-usb.rules 并添加一个设备规则来做到这一点 SUBSYSTEM=="tty", ATTRS{serial}=="1234567", SYMLINK+="device1"
什么是 Mac 等价物?提前致谢。
...也许这就像 /dev/tty.usb > /dev/device1 的普通符号链接一样简单
我试图找出是否有办法让鼻子测试跑步者运行所有测试,除了具有特定标签的测试.看起来这可以通过属性实现,但我不知道是否有办法用标签来做,标签是属性的一个子集.
目前我通过调用使用标签
nosetests -a tags='tag'
Run Code Online (Sandbox Code Playgroud)
我的标记测试看起来像:
@attr(tags=['foo', 'bar', 'baz'])
def test_some_stuff(self):
Run Code Online (Sandbox Code Playgroud)
但如果我想运行除'baz'标记之外的所有测试,我该怎么做?
我试过像
nosetests -A 'not baz'
nosetests -a '!baz'
nosetests tags='!baz'
Run Code Online (Sandbox Code Playgroud)
但是这些似乎对属性没有任何影响.我没有看到在文档中排除标记的示例:http://nose.readthedocs.org/en/latest/plugins/attrib.html
我宁愿不必添加一个新标签,只是为了排除我正在使用的这个大型测试套件,并且必须记住总是添加一个假的"排除标签".
由于paramiko 2.0将其依赖性从pycrypto更改为加密,因此通过pip安装最新的Ansible失败.密码学依赖于cffi,这需要libffi-dev.有谁知道如何解决这一问题?(Ubuntu Trusty 14.04)
RUN pip install --upgrade ansible
---> Running in 8ef89649c480
Collecting ansible
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not …Run Code Online (Sandbox Code Playgroud)