我需要能够通过在Linux shell中键入一行来在当前目录中运行所有测试.在某些目录中,这很好用.但在其他情况下,当我输入"nosetests"时,没有进行任何测试.如果我单独调用它们,测试将运行,但我需要它们全部自动运行.这是一个不起作用的目录:
/extwebserver
__init__.py
test_Detection.py
test_Filesystem.py
test_Hardware.py
...
Run Code Online (Sandbox Code Playgroud)
当我在父目录中运行"nosetests"时,将运行某个子目录中的所有测试,但不会运行/ extwebserver或其他子目录或父目录本身的测试.
编辑 这是输出:
matthew@Matthew-Laptop:~/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing$ nosetests -vv --collect-only
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/baseTestCase.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/run.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/test_Detection.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/test_Filesystem.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/test_Hardware.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/test_Mode.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/test_System.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/test_View.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/extwebserver/test_Webserver.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/mocks/bottle.py is executable; skipped
nose.selector: INFO: /home/matthew/Documents/ParkAssist/m3/linux/appfs/master/usr/bin/piopio/testing/utils/test_timestamps.py is …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Mock来模拟python中的一个函数.这是我的代码:
resp, content = request(...)
Run Code Online (Sandbox Code Playgroud)
request()函数需要返回两个值.这是我试过的:
with patch("syncdatetime.py") as sync_mock:
sync_mock.request.return_value = [obj, '']
Run Code Online (Sandbox Code Playgroud)
但是当我运行测试时,我得到错误"模拟对象不可迭代".请求函数返回Mock类型的对象而不是列表.如何修改请求函数以便返回列表?
我正在尝试在Ubuntu 11.04上使用bjam编译一个C++项目.我一直收到以下错误:
../../libraries/boost_1_44_0/boost/python/detail/wrap_python.hpp:75:24: fatal error: patchlevel.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)
我搜索了我的项目目录,有几个名为patchlevel.h的文件,但我不知道它们是什么.它们是Boost的一部分吗?
我也多次得到这个错误:
pa-vision-lib/../captureformat.h:4:25: fatal error: linux/ovcam.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)
这个文件也肯定存在.在我需要更改为指向这些文件的任何Boost配置文件中是否存在某种路径设置?
我正在运行Python 2.7,我正在尝试创建一个JSONEncoder的自定义FloatEncoder子类.我跟着很多例子,如本,但似乎没有工作.这是我的FloatEncoder类:
class FloatEncoder(JSONEncoder):
def _iterencode(self, obj, markers=None):
if isinstance(obj, float):
return (str(obj) for obj in [obj])
return super(FloatEncoder, self)._iterencode(obj, markers)
Run Code Online (Sandbox Code Playgroud)
这里是我调用json.dumps的地方:
with patch("utils.fileio.FloatEncoder") as float_patch:
for val,res in ((.00123456,'0.0012'),(.00009,'0.0001'),(0.99999,'1.0000'),({'hello':1.00001,'world':[True,1.00009]},'{"world": [true, 1.0001], "hello": 1.0000}')):
untrusted = dumps(val, cls=FloatEncoder)
self.assertTrue(float_patch._iterencode.called)
self.assertEqual(untrusted, res)
Run Code Online (Sandbox Code Playgroud)
第一个断言失败,意味着_iterencode没有被执行.在阅读JSON文档之后,我尝试重写default()方法,但也没有被调用.
对于我的计算机网络课程,我正在尝试使用带有ICMP协议的原始套接字来实现Traceroute.我需要构建一个数据包,然后使用Python结构类解包响应数据包.以下是构建数据包的代码:
header = struct.pack("bbHHh", ICMP_ECHO_REQUEST, 0, myChecksum, pid, 1)
data = struct.pack("d", time.time())
packet = header + data
Run Code Online (Sandbox Code Playgroud)
之后,我收到了与确认格式相同的ICMP数据包.以下是解包数据包的代码:
request_code, request_type, checksum, packet_id, \
sequence, timeSent, data = struct.unpack("bbHHhd", recvPacket)
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:struct.error: unpack requires a string argument of length 16
.
我不明白,因为当我检查struct.calcsize()
格式字符串时,它返回16.
如果你想在你的机器上运行它,这是我的完整程序
from socket import *
import socket
import os
import sys
import struct
import time
import select
import binascii
ICMP_ECHO_REQUEST = 8
MAX_HOPS = 30
TIMEOUT = 2.0
TRIES = 2
# The packet that we …
Run Code Online (Sandbox Code Playgroud) 我知道有很多问题,但没有一个帮助我的情况.我正在运行Ubuntu 11.10,我正在尝试在LG手机上调试应用程序.我按照本指南操作:http://developer.android.com/guide/developing/device.html
我在手机上启用了USB调试,在清单中将项目设置为可调试,并编辑了/etc/udev/rules.d/51-android.rules规则文件.这是文件的内容:
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="plugdev"
Run Code Online (Sandbox Code Playgroud)
1004是LG的供应商ID.该设备已安装; 我可以在我的文件系统中访问它,USB挂载指示器位于通知区域.当我运行adb设备时,手机未列出,只有模拟器.它在Eclipse中也不被认可.如何让Eclipse识别我的设备?
python ×5
android ×1
boost ×1
boost-build ×1
debugging ×1
icmp ×1
json ×1
mocking ×1
networking ×1
nose ×1
raw-sockets ×1
sockets ×1