我正在编写Python script
来过滤一些log
文件,我想用正则表达式过滤文本/某些库(preferred regex
,因为我想避免依赖虚拟环境)。以下是我想要查找的文字/句子:
Failed to find the annotation and the status of the test public void com.somename.qa.mobile.tests.somename.SomeTest.testSomeName(). The result is not deployed to Platform but we will proceed with further tests
这种类型的行可能在控制台日志中出现20次。我想找到每个实例,并为每个实例获取该方法名称somename.SomeTest.testSomeName()
(最终我会收集所有名称并向我发送一封电子邮件......但这是后来的部分)
到目前为止,我已尝试'\[([^\]]+)\] somename.SomeTest.testSomeName() ([^ ]+)'
找到该模式。但我对正则表达式并不擅长,可能会做一些额外/不正确的事情。
已编辑:
更改/扩展我想要找到的正则表达式的文本/字符串:somename.SomeTest.testSomeName()
对我来说。
21:18:19 at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:170)
21:18:19 at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:84)
21:18:19 at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:92)
21:18:19 at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
21:18:19 at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
21:18:19 at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
21:18:26 2016-05-12 21:18:25.238 [ERROR] (1): Failed to find the annotation and the status of the test public void com.somename.qa.mobile.tests.somename.SomeTest.testSomeName(). The result is not deployed to Platform but we will proceed with further tests
21:18:26 somename.client.test.utilities.Platform.PlatformApiException: Platform API returned HTTP 400("Field :case_id is not a valid test case.")
21:18:26 at somename.client.test.utilities.platform.PlatformApiClient.sendRequest(PlatformApiClient.java:197)
21:18:26 at