使用以下代码:
import pytest
def test_a():
with pytest.raises(Exception):
1/0
Run Code Online (Sandbox Code Playgroud)
如果我对它运行pylint,它会抱怨"raises"不是模块pytest的成员:
E: 3,9:test_a: Module 'pytest' has no 'raises' member
Run Code Online (Sandbox Code Playgroud)
这显然不是真的.知道为什么pylint犯了这样的错误吗?这是一个已知的错误?
py.test版本:
> py.test --version
This is py.test version 2.2.3, imported from C:\Python27\lib\site-packages\pytest.pyc
Run Code Online (Sandbox Code Playgroud)
PyLint版本:
> pylint --version
No config file found, using default configuration
pylint 0.25.1,
astng 0.23.1, common 0.57.1
Python 2.7.2 (default, Jun 24 2011, 12:22:14) [MSC v.1500 64 bit (AMD64)]
Run Code Online (Sandbox Code Playgroud) 我想解析一些语法,如下所示
OUTPUT data
GROUPBY key
TO location
USING object
Run Code Online (Sandbox Code Playgroud)
子句的顺序GROUPBY TO USING允许变化,但每个子句最多出现一次。
在 FParsec 中是否有方便或内置的方法来解析它?我读了一些提到 Haskell Parsec 排列的问题和答案。FParsec 中似乎没有排列。如果这是要走的路,我会如何在 FParsec 中构建排列?
我有一个脚本调用“ a.ps1”:
write-host "hello host"
"output object"
Run Code Online (Sandbox Code Playgroud)
我想调用脚本并获取输出对象,但我也希望取消标准输出:
$result = .\a.ps1
# Don't want anything printed to the console here
Run Code Online (Sandbox Code Playgroud)
有什么提示吗?
我需要与这个问题完全相反的行为.我的观察是,当按下enter位置列表窗口中的一行时,窗口将被关闭,主窗口将显示所选文件的内容.相反,quickfix窗口没有这种行为,即它在选择后保持打开状态.
我检查了我的autocmd,没有特殊处理位置列表或quickfix列表.
示例 - :lgrep hi *填充位置列表.lopen打开位置列表窗口.按enter任意一行.
使用此程序 ( cs.exe):
class Program
{
static void Main(string[] args)
{
foreach (var item in args)
{
Console.WriteLine(item);
}
}
}
Run Code Online (Sandbox Code Playgroud)
并运行:
> cs.exe go\to\a_path
go\to\a_path
> cs.exe "go\to\a path"
go\to\a path
> cs.exe "go\to\a path\"
go\to\a path"
> cs.exe 'go\to\a path\'
'go\to\a
path\'
Run Code Online (Sandbox Code Playgroud)
这意味着如果你的路径有一个空格所以你引用它,要非常小心不要\在末尾放一个尾随,否则你的程序可能无法处理它,因为它"在末尾错误地包含了 a 。单引号更奇怪!
PowerShell 表现出类似的行为,但没有单引号和双引号之间的区别。
我如何理解这种行为?在 cmd 中评估反斜杠的基本规则是什么,以便可以一致地解释?
对于每个新创建的C#项目,Visual Studio 2010都添加了一些默认引用,例如System,System.Core,System.Xml等.这些默认引用的好处是您可以直接使用它们而无需手动添加它们.
我想知道是否有办法添加第三方程序集作为默认引用,这样我每次创建项目时都不需要添加它.
在Windows上我有一个从stdin读取的程序(prog.exe).在python中我想管道一个字符串作为其stdin的输入.怎么做?
就像是:
subprocess.check_output("echo {0} | myprog.exe".format(mystring))
Run Code Online (Sandbox Code Playgroud)
或者(使args成为一个列表)
subprocess.check_output("echo {0} | myprog.exe".format(mystring).split())
Run Code Online (Sandbox Code Playgroud)
似乎不起作用.它给了我:
WindowsError: [Error 2] The system cannot find the file specified
Run Code Online (Sandbox Code Playgroud)
我还尝试使用StringIO的"stdin"关键字arg(这是一个类似文件的对象)
subprocess.check_output(["myprog.exe"], stdin=StringIO(mystring))
Run Code Online (Sandbox Code Playgroud)
仍然没有运气 - check_output不适用于StringIO.
我正在ffmpeg我的笔记本电脑上构建一个简单的命令行来从其相机流式传输.命令行读取(详细信息):
host1> ffmpeg -v verbose \
-f dshow \
-i video="Camera":audio="Microphone" \
-r 30 -g 0 -vcodec h264 -acodec libmp3lame \
-tune zerolatency \
-preset ultrafast \
-f mpegts udp://12.34.56.78:12345
Run Code Online (Sandbox Code Playgroud)
首先,它在本地工作.即,我可以通过ffplay在同一主机上使用来查看输出:
host1> ffplay -hide_banner -v udp://12.34.56.78:12345
Run Code Online (Sandbox Code Playgroud)
现在,当我从同一网络中的另一台机器执行此操作时,无法正常工作.它显示了一个nan进步:
host2> ffplay -hide_banner -v udp://12.34.56.78:12345
nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
Run Code Online (Sandbox Code Playgroud)
我ncat以前转储原始内容.但是没有输出:
host2>\ncat\ncat -v -u 12.34.56.78 12345
Ncat: Version 5.59BETA1 ( http://nmap.org/ncat )
Ncat: Connected to 12.34.56.78:12345.
(...and nothing …Run Code Online (Sandbox Code Playgroud) 我对这个问题有类似的问题.而是我的SomeClass工具SomeInterface.在这种情况下,即使我标记SomeClass为sealed,编译器时间类型检查仍然没有启动.例如下面.
编译器类型检查对我来说很重要,因为我正在重构一个大项目,将枚举源(source在a中foreach (SomeClass foo in source))更改IEnumerable<SomeClass>为IEnumerable<SomeInterface>.有时我忘记将循环中的枚举器类型声明更改SomeClass为SomeInterface,并且项目仍然编译.那会破坏事情真的很糟糕!!
请注意,我无法将循环变量类型更改为隐式,var因为它正在退出代码库.但我能够更改接口的声明及其具体的实现类.
class Program
{
static void Main(string[] args)
{
IEnumerable<SomeInterface> someFoos = new SomeInterface[] { new SomeOtherClass(), new SomeOtherClass(), new SomeOtherClass() };
foreach (SomeClass foo in someFoos)
{
foo.ToString(); // runtime InvalidCastException
}
}
}
interface SomeInterface { }
sealed class SomeClass : SomeInterface
{
public override string …Run Code Online (Sandbox Code Playgroud)