admin管理员组文章数量:1123430
For some reason the Json contract file Pact generates after running the test I created is being saved to the project's root folder instead of using the path I have defined on its configuration. This application is running in WSL, and it saves to the wrong place in the virtual environment and in my local folder, too.
I have used their example from their documentation and tried writing the path in different ways, but nothing seems to work.
I'm using pact-python>=2.2.2
, and installed it using uv.
This is what I added to my conftest.py file:
@pytest.fixture(scope="module")
def pact() -> Generator[Pact, None, None]:
consumer = Consumer("Consumer")
pact_dir = Path(Path(__file__).parent / "contract/pacts")
pact = consumer.has_pact_with(
Provider("Provider"),
pact_dir=pact_dir,
# publish_to_broker=True,
# Mock service configuration
# host_name=MOCK_URL.host,
# port=MOCK_URL.port,
# Broker configuration
# broker_base_url=str(broker),
# broker_username=broker.user,
# broker_password=broker.password,
)
pact.start_service()
yield pact
pact.stop_service()
I ran the test in debug mode, checked the pact_dir
and it is set as it's supposed to be.
PosixPath('/mnt/c/project/tests/contract/pacts')
I'm starting to suspect it could be an issue with Pact itself, but can't be sure.
本文标签: pythonPact file not being saved to configured directoryStack Overflow
版权声明:本文标题:python - Pact file not being saved to configured directory - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736570379a1944763.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论