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

Drop PyPI mock dependency; use unittest.mock instead #188

Closed

Conversation

musicinmybrain
Copy link
Contributor

This is available in the Python standard library from version 3.3; sure advertises support for 3.6 and later in setup.py

Pull Request Type

Please specify the type of the pull request you want to submit:

  • Bugfix
  • New Feature
  • Documentation Only
  • Testing Only
  • ...

Summary

Since unittest.mock is in the Python standard library, the external dependency is unnecessary.

See also https://fedoraproject.org/wiki/Changes/DeprecatePythonMock; furthermore, an effort is underway to retire the python-mock package from Fedora Linux in a near-future release.

This is available in the Python standard library from version 3.3; sure
advertises support for 3.6 and later in setup.py
@musicinmybrain
Copy link
Contributor Author

This PR only handles the mock/unittest.mock change. Removing the nose dependency and supporting pytest as in #161 would be even nicer, of course!

@musicinmybrain
Copy link
Contributor Author

See also https://fedoraproject.org/wiki/Changes/DeprecatePythonMock; furthermore, an effort is underway to retire the python-mock package from Fedora Linux in a near-future release.

This is happening in the upcoming Fedora 40 release (F40 Change Proposal: Remove Python Mock Usage (System-Wide)), so I’m applying this PR as a downstream patch in Fedora Linux.

@gabrielfalcao
Copy link
Owner

@musicinmybrain the master branch presently moves code related to mock into sure.doubles.mocks along with a brief reasoning as to why.

@musicinmybrain
Copy link
Contributor Author

@musicinmybrain the master branch presently moves code related to mock into sure.doubles.mocks along with a brief reasoning as to why.

I think I understand what you are doing there with respect to typing, but I am still working to understand the full context:

  • Why work around two possible “flavors” of _CallList rather than removing the mock dependency and always using unittest.mock? Is it because you expect that some users have code with mock.mock._CallList and you need to integrate with that?
  • Are you planning to remove the PyPI mock dependency soon? Can it at least be downgraded to a test dependency that can be more easily patched out?

@gabrielfalcao
Copy link
Owner

@musicinmybrain the master branch presently moves code related to mock into sure.doubles.mocks along with a brief reasoning as to why.

I think I understand what you are doing there with respect to typing, but I am still working to understand the full context:

  • Why work around two possible “flavors” of _CallList rather than removing the mock dependency and always using unittest.mock? Is it because you expect that some users have code with mock.mock._CallList and you need to integrate with that?

The primary hypothesis in this case is that in supporting only unittest.mock._CallList, an inconsistent behavior could emerge in codebases using mock.mock._CallList. Nevertheless, the only logical reasoning applied in deciding to keep supporting mock._CallList entirely based on the following test:

from unittest.mock import _CallList as _CallList_
from mock.mock import _CallList
assert _CallList_ != _CallList
  • Are you planning to remove the PyPI mock dependency soon? Can it at least be downgraded to a test dependency that can be more easily patched out?

Sure, that sounds reasonable.

@gabrielfalcao
Copy link
Owner

Fixed on release 3.0a1

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

2 participants