https://fedoraproject.org/wiki/Changes/DeprecatePythonMock


== Summary ==
The {{package|python-mock}} ({{package|python3-mock}}) package will be
[https://docs.fedoraproject.org/en-US/packaging-guidelines/deprecating-packages/
deprecated] in [[Releases/34|Fedora 34]]. The package is a standard
library backport for older Pythons, Fedora packages should use
`unittest.mock` instead. Many still depend on `mock`, so we cannot
remove it yet. Packagers are encouraged to work with upstream to
switch to `unittest.mock` when available. A simple `sed` can be
applied in `%prep` as a temporary (or even permanent) downstream
solution.

== Owner ==
* Name: [[User:Churchyard|Miro Hrončok]]
* Email: mhron...@redhat.com


== Detailed Description ==
The {{package|python-mock}} package is the
[https://pypi.org/project/mock/ 3rd party backport of the standard
library `unittest.mock` module].

> mock is now part of the Python standard library, available as 
> [https://docs.python.org/dev/library/unittest.mock.html unittest.mock] in 
> Python 3.3 onwards.
> This package contains a rolling backport of the standard library mock code 
> compatible with Python 3.6 and up.

Fedora has recent enough versions of Python, hence using a library
backport is redundant. Many packages only use it out of habit. We'd
like to encourage both downstream packages and upstreams to switch to
[https://docs.python.org/dev/library/unittest.mock.html unittest.mock]
instead. Eventually, we'd like to drop {{package|python-mock}} from
Fedora entirely, if possible. Before we attempt to remove the package,
we need to stop new packages to (Build)Require
{{package|python3-mock}}, hence we want to have it
[https://docs.fedoraproject.org/en-US/packaging-guidelines/deprecating-packages/
deprecated].

Note that the change owner does not currently officially maintain
{{package|python-mock}} but the Python Maintenance team maintains the
package in RHEL and contributes to the Fedora package when needed. The
Fedora package maintainers have been contacted without response.

=== How to migrate to unittest.mock ===

In most cases, performing the following replacement should be enough:

 s/^(\s*)import mock/\1from unittest import mock/
 s/^(\s*)from mock import /\1from unittest.mock import /

If upstream really needs to support Python versions without
`unittest.mock`, we recommend using a `try-import` mechanism, such as:

 try:
     from unittest import mock
 except ImportError:
     import mock

If dual support for `unittest.mock` and `mock` is required, and the
`mock` package is required in the metadata (such as in the testing
''extras''), conditionalize it, with:

 mock;python_version<"3.3"

== Feedback ==
In the past, we've managed to migrate some packages away from
python-mock, without a push back:

* https://src.fedoraproject.org/rpms/python-urllib3/pull-request/13
* https://src.fedoraproject.org/rpms/python-freezegun/pull-request/10
* https://src.fedoraproject.org/rpms/python-hypothesis/c/65a4191709

== Benefit to Fedora ==
Eventually, we might be able to no longer maintain a standard library
backport in a separate package.

== Scope ==
* Proposal owners: Deprecate {{package|python3-mock}} and update the
package description. Provide help migrating to `unittest.mock` to
other packagers who ask for it.

* Other developers: No action needed. Don't add new dependencies on
{{package|python3-mock}}. If interested, migrate existing packages to
`unittest.mock` (feel free to ask for help)
* Release engineering: no impact on Release Engineering is anticipated
* Policies and guidelines: N/A (not a System Wide Change)
* Trademark approval: N/A (not needed for this Change)
* Alignment with Objectives:  N/A (not needed for this Change)


== Upgrade/compatibility impact ==
The package will remain available. Only new packages cannot depend on it.
Once retired (in distant future), we don't plan to obsolete/provide
<code>python3-mock</code> from {{package|python3-libs}}, because it
cannot work as drop-in replacement (the import name is different). The
package will eventually be obsoleted by
{{package|fedora-obsolete-packages}} once Python is updated to 3.N+1
after the removal to avoid broken upgrades.

== How To Test ==
 $ repoquery --repo=rawhide --provides python3-mock
 ...
 deprecated()
 ...

== User Experience ==
No changes.

== Dependencies ==
N/A (not a System Wide Change)

== Contingency Plan ==
* Contingency mechanism: (What to do?  Who will do it?) N/A (not a
System Wide Change)
* Contingency deadline: N/A (not a System Wide Change)
* Blocks release? N/A (not a System Wide Change)
== Documentation ==
N/A (not a System Wide Change)


-- 
Ben Cotton
He / Him / His
Senior Program Manager, Fedora & CentOS Stream
Red Hat
TZ=America/Indiana/Indianapolis
_______________________________________________
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org

Reply via email to