#4239 unittest: use unittest.mock instead of mock
Merged by mikem. Opened by julian8628.
julian8628/koji unittest-mock  into  master

Download 4239.patch

because of the absence of unittest.mock on python2.7, we still fallback to mock

fixes: #4195

Metadata Update from @julian8628:
- Pull-request tagged with: no_qe

4 new commits added

  • setuptools is required by devtools/check-api (py3)
  • sort imports in tests/
  • fix unittest without /usr/bin/python on newer os
  • unittest: use unittest.mock instead of mock

2 new commits added

  • sort imports in tests/
  • unittest: use unittest.mock instead of mock

Metadata Update from @jcupova:
- Pull-request untagged with: no_qe

dropping no_qe tag until review is completed

This seems fine overall.

Technically, we only need to worry about the fallback import for the py2-relevant tests, but should be harmless to have it everywhere.

You've added a commit to sort imports, which seems reasonable given that we're creating a lot of churn in that area anyway. However, your sort does not quite agree with what isort does for me locally. If I run isort tests, I see a number of changes across hundreds of files on top of what you have here. Mainly:

  • adding a blank line before relative imports
  • some additional re-ordering (e.g. moving koji_cli import in tests/test_cli/test_add_host.py)
  • some adjustments to long import lists

There are a handful of test files that isort wants to change that were not otherwise changed by your PR, but the vast majority overlap with your PR. Are we seeing variation in isort behavior? I've got python3-isort-5.13.2-1.fc39.noarch.

Guessing the differences are caused by different isort config here: https://pagure.io/koji/pull-request/4243#_1__23-31

I can drop the import sorting commit and we could probably deal it in #4243

Technically, we only need to worry about the fallback import for the py2-relevant tests, but should be harmless to have it everywhere.

I added the fallback import in tests/test_lib so that it can be checked with py2 as well (it would have been added as koji lib still supports py 2.7). I submitted PR #4248 for this

rebased onto 589e6bbb960421b6835a61d1d0c0622b27357405

I can drop the import sorting commit and we could probably deal it in #4243

removed

Technically, we only need to worry about the fallback import for the py2-relevant tests

ah, my mistake, you only have the fallback in build/cli/lib/plugins tests. Easy to miss with 390 files changed ;)

:thumbsup:

Metadata Update from @mikem:
- Pull-request tagged with: no_qe

Commit 57040f73 fixes this pull-request

Pull-Request has been merged by mikem

Metadata