admin管理员组文章数量:1241124
Initially, I have this code to connect to an Elasticsearch artifact and upload the initial documents to it. This part works well, and the index those documents are in exist and the documents exist as well. These all use @Given
and @And
from pytest.
However the next part is to run a custom command which originates from another file, and the command was made using typer
. This part uses the @When
from pytest. So it’s like “When the command is run a new index is created which consists of documents where the name files are similar and those with similar names joined into one document”.
Then the next and last method uses the @Then
and is supposed to get from the newly created index for matching pairs and compare against an expected_output.json. Haven’t even gotten here though because the new index isn’t been being created by the custom command. It’s something like this:
@When(custom command is run, pairs are generated)
def run_command():
os.environ[elastic_env] = local
subprocess.run(command.split(“ “))#Goes through a bunch of methods to create the new index and generate the pair documents to put in it
@Then(“documents from new index match the ones in expected output file”)
def check_against_output(context):
client = context[‘es_client’] #context from another pytest fixture
output = client.indices.search(index = “new_index”, query = “match all {}”)
But the subprocess doesn’t throw an error, so it just runs the command but does nothing, so the index never gets created, so I get a no index found exception in check_against_output
. Any ideas for why the subprocess isn’t working? I tried changing Elasticsearch instance scope to modular, and I tried using os.system
as well. Works in the terminal and Python shell. I’m in WSL using Ubuntu:22.04. Any help is appreciated, thank you.
本文标签: elasticsearchPython subprocess not running inside pytest methodStack Overflow
版权声明:本文标题:elasticsearch - Python subprocess not running inside pytest method - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740027010a2221054.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论