-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iso_8601_datetime matcher does not work on Windows #850
Comments
Thanks for the bug report and for including an example! Could you please let me know which version of Python you are using? And just to (re)confirm, you are using the latest version of Pact Python? |
yes. Python 3.11 using venv and pact-python 2.2.2 The same problem happens using python 3.10 with conda as env I have tested with diff venv because I was thinkg that could be something related to virtual env. But does not seems to be |
Given this is a Windows-specific issue, can you please help me out and double check the output of the following: from datetime import datetime, timezone
print(datetime.now(tz=timezone.utc).isoformat()) or as a console one-liner: python -c "from datetime import datetime, timezone; print(datetime.now(tz=timezone.utc).isoformat())" |
output: |
Signed-off-by: JP-Ellis <[email protected]>
I am able to replicate your issue, but can't fix it at this stage (though I will keep trying for a bit). Is there any chance you can use the Pact Python v3 interface (form the So my investigation ultimately uncovered the issue to be due to the use of spaces in both the consumer and providers. It is unclear to me why this works on Linux/macOS and not Windows. Most likely, this is actually an issue with the underlying As such, I suspect this won't be fixed in V2; however, I have added warnings into Pact to catch this. Can you please confirm that the space in the name is the issue? Once confirmed, I'll merge #858 and close this issue. |
Signed-off-by: JP-Ellis <[email protected]>
Hey @JP-Ellis , ok. I will use v3. I have tried remove the space at MessageConsumer name, but the issue still happens. So I am not able to confirm it for you |
Discoeverd by user-reported issue in #850. Signed-off-by: JP-Ellis <[email protected]>
So I updated the test in #858 to specifically incorporate the behaviour you are seeing: pact-python/tests/test_issue.py Lines 13 to 44 in da3c9d4
And the CI tests succeeded on all platforms, indicating that the Pact JSON file was created on the Linux and macOS runners, and failed to be created on the Windows runner. Can you make sure that both consumer and provider names have no spaces? As far as I can tell, the issue is unrelated to the ISO 8601 datetime matchers. |
Hey @JP-Ellis, unfortunately, at least in my env, removing the space from provider and consumer name did not solved the issue |
The screenshot shows that you are interrupting the Python process during the invocation of the underlying Your original question was specifically about he ISO 8601 matcher; can you confirm that this is the culprit? I do see that your URL decoded window shows a datetime which is not ISO 8601 compliant; however I do not know where this window comes from. Pycharm may be using its own formatting to display variables during a debug session. Are you able to provide any debug logs? Or better yet, are you able to adapt the example I made in #858 to replicate your issue? So in summary, to try and pinpoint what's going on:
|
@azosramonsaraiva Where you able to test out any of the pointers I suggested in my previous post? Without being able to replicate your exact issue, it is difficult for me to help out. |
@JP-Ellis
2024-11-25.09-58-25.mp4 |
Wow awesome thanks for the video! That is such strange behaviour! The network path not found error looks like an underlying OS issue, which makes it very confusing as to why the ISO 8601 matcher would cause an issue. I'll spin up a virtual Windows machine to see if I can replicate it. Just to double check one other thing, what happens if you run the script from the terminal (as opposed to your IDE's 'run' button)? E.g.: python consumer.py Do you will have the same issue with the ISO 8601 matcher? And does it go away when the ISO 8601 matcher is removed? My small hypothesis being tested here is whether PyCharm is injecting anything at runtime (e.g., for debugging). |
Have you read the Contributing Guidelines on issues?
Prerequisites
pact-python
.Description
When using MessageConsumer and attempting to set an iso_8601_datetime matcher, the pact file generation fails on Windows. This issue does not occur on Linux, where it works as expected.
Reproducible demo
No response
Steps to reproduce
Run this script on windows:
Please note that the file will not be generated.
If you set a breakpoint on message_pact.py, line 193, you can observe that the issue occurs during:
json.dumps(self._messages[0]),
It seems to be something related with regex and json dumps
Remember: it only happens on windows
Expected behavior
The file must be generated on windows
Actual behavior
If matchers.Format().iso_8601_datetime() is used, the local pact file is not being generated on windows
Your environment
Windows 11
Self-service
The text was updated successfully, but these errors were encountered: