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

Add unittest.mock backport #98

Merged
merged 1 commit into from
Apr 27, 2020
Merged

Conversation

ruaridhw
Copy link
Contributor

Fixes:

Summary/Motivation:

  • To allow usage of unittest.mock in packages that import pyutilib.th as unittest

Changes proposed in this PR:

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@jsiirola
Copy link
Contributor

It looks like the hard dependence on the mock library might be causing problems (I rarely use mock, and in our other discussion missed that mock was a separate package before Python 3.3). I am not sure how others will feel about adding another dependency. At a minimum, we should promulgate the mock from unittest in Python3:

if six.PY3:
    from unittest import mock
else:
    import mock

I wonder if it also makes sense to make the dependency optional:

if six.PY3:
    from unittest import mock
    mock_available = True
else:
    try:
        import mock
        mock_available = True
    except ImportError:
        mock_available = False

Thoughts?

@ruaridhw
Copy link
Contributor Author

Updated accordingly though I figured that using Python3 doesn't necessarily imply that mock exists in unittest since it wasn't around in 3.0

@jsiirola
Copy link
Contributor

@ruaridhw: correct, but PyUtilib explicitly doesn't support 3.0-3.3, so we can be lazy.

setup.py Outdated
@@ -26,7 +26,8 @@ def read(*rnames):
break
return line + README.read()

requires=[ 'nose', 'six' ]

requires = ['nose', 'six', 'mock==3.0.5']
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert the change to the required dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

- To allow usage of `unittest.mock` in packages that import pyutilib.th as unittest
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 61.919% when pulling ceada22 on flexciton:feat/mock into 6f02a99 on PyUtilib:master.

@jsiirola jsiirola merged commit 10b7bb3 into PyUtilib:master Apr 27, 2020
@ruaridhw ruaridhw deleted the feat/mock branch April 27, 2020 15:46
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.

None yet

3 participants