Skip to content
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

workaround for python3.5 UTs build setup and replace assert_called_once mock method #3191

Merged
merged 5 commits into from
Aug 26, 2024

Conversation

nagworld9
Copy link
Contributor

@nagworld9 nagworld9 commented Aug 26, 2024

Description

Python3.5 setup fails with invalid ssl cert while fetching pip ( Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:728) - skipping)
Added workaround for it as mentioned on this thread actions/setup-python#866

This pr also addresses some of the unit tests failing on python3.5 due to assert_called_once attribute not found error and same thing, we saw it in container as well

    mock_stream.assert_called_once()
  File "/usr/lib/python3.5/unittest/mock.py", line 583, in __getattr__
    raise AttributeError(name)
AttributeError: assert_called_once

I found out that assert_called_once is not available before < 3.6 and using this will produce unexpected behavior. It seems we should avoid using as per this https://web.archive.org/web/20210919045841/http://engineroom.trackmaven.com/blog/mocking-mistakes/

https://web.archive.org/web/20211009193419/https://docs.python.org/3.5/library/unittest.mock.html
https://stackoverflow.com/questions/42297549/magic-mock-assert-called-once-vs-assert-called-once-with-weird-behaviour

Issue #


PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • If applicable, the PR references the bug/issue that it fixes in the description.
  • New Unit tests were added for the changes made

Quality of Code and Contribution Guidelines

@@ -88,6 +88,8 @@ jobs:
matrix:
include:
- python-version: "3.5"
# workaround for issue "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:728)" on Python 3.5
pip_trusted_host: "pypi.python.org pypi.org files.pythonhosted.org"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good find; could you add actions/setup-python#866 to the comment?

@nagworld9 nagworld9 merged commit ef87f40 into Azure:develop Aug 26, 2024
10 of 11 checks passed
@nagworld9 nagworld9 deleted the python3.5 branch August 26, 2024 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants