我正在尝试在 python 3.6 中使用 scapy 来解析 pcap 文件,我尝试使用的功能是 pdfdump。
from scapy.all import *
packets = rdpcap('***path***/nitroba.pcap')
for packet in packets[0:1]:
packet.psdump("isakmp_pkt.eps",layer_shift=1)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:“ImportError: PyX and its depedencies must be installed”
显然我安装了它,一个简单的“import pyx”工作,但错误仍然存在。我做了一些挖掘,发现问题出在这段代码中:
def _test_pyx():
"""Returns if PyX is correctly installed or not"""
try:
with open(os.devnull, 'wb') as devnull:
r = subprocess.check_call(["pdflatex", "--version"], stdout=devnull, stderr=subprocess.STDOUT)
except:
return False
else:
return r == 0
Run Code Online (Sandbox Code Playgroud)
执行时,它确定 pyx 是否安装正确,但显示“FileNotFoundError: [WinError 2] 系统找不到指定的文件”。
想法?
我有以下课程:
public class MyClassTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void testMyMethod() throws Exception {
// Test 1
String[] args = ...;
MyClass.myMethod(args);
// Test 2
thrown.expect(InvalidParamException.class);
thrown.expectMessage("exceptionString 1");
args = ...;
MyClass.myMethod(args);
// test 3
thrown.expect(InvalidParamException.class);
thrown.expectMessage("exceptionString 2");
args = ...;
MyClass.myMethod(args);
}
Run Code Online (Sandbox Code Playgroud)
问题是测试2中的expectMessage是错误的,为了讨论,实际预期的消息是exceptionString 3,但测试没有失败,尽管预期的消息与实际的消息不同.它变得更奇怪 - 如果我向expectMessage提供诸如"fdsfsdfsdfsdfsdfsdthe"之类的乱码信息 - 那么测试确实会失败:
java.lang.AssertionError:预期:( InvalidParamException和异常的实例,消息包含一个包含"fdsfsdfsdfsdfsdfsdthe"的字符串)但是:带有消息的异常,包含"fdsfsdfsdfsdfsdfsdthe"消息的字符串是"exceptionMessage3"
这是预期的行为 - 但是当我更改exceptionMessage3一点点,字母或两个,甚至发送一个空字符串时 - 测试根本不会失败.
我错过了什么吗?