我的一些 pytest 固定装置返回一个方法。我想对我的所有方法使用类型提示。说一个方法返回一个我可以Callable
在这里使用的方法。这里的问题是:我失去了 IDE PyCharm 中参数的自动完成功能。
没有给出夹具返回值的类型提示:
@pytest.fixture
def create_project():
def create(location: Path, force: bool = True) -> bool:
# ...
return create
def test_project(create_project):
project_created = create_project()
Run Code Online (Sandbox Code Playgroud)
使用给定的类型提示:
@pytest.fixture
def create_project() -> Callable[[Path, bool], bool]:
def create(location: Path, force: bool = True) -> bool:
# ...
return create
def test_project(create_project):
project_created = create_project()
Run Code Online (Sandbox Code Playgroud)
另一个问题Callable
是,我必须在夹具中以及在我使用该夹具的每个测试中描述一次参数和返回类型。
那么有没有更有效的方法呢?
使用--pipe -N<int>
I 可以发送给定数量的行作为由 启动的作业的输入parallel
。:::
但是我怎样才能运行多个作业,并在每个块上给出不同的参数呢?
让我们看一下这个小输入文件:
A B C
D E F
G H I
J K L
Run Code Online (Sandbox Code Playgroud)
此外,我们定义将每两行通过管道传输到一个parallel
作业。cut -f<int>
在它们上,应该使用作为并行输入参数给出的列号来执行命令,例如::: {1..3}
因此对于给定的示例,输出将如下所示
A
D
B
E
C
F
G
J
H
K
I
L
Run Code Online (Sandbox Code Playgroud)
我尝试过这个命令:
cat input.txt|parallel --pipe -N2 'cut -f{1}' ::: {1..3}
Run Code Online (Sandbox Code Playgroud)
但输出是这样的:
A
D
I
L
Run Code Online (Sandbox Code Playgroud)
我缺少什么?
鳍游泳者