[PATCH] migrate from external mock package to stdlib unittest.mock

25 views
Skip to first unread message

Eli Schwartz

unread,
Dec 3, 2023, 7:13:41 PM12/3/23
to thg...@googlegroups.com
It was moved to the stdlib in python 3.3, and the PyPI version is a
backport for python versions less than 3.3.
---
.gitlab-ci.yml | 20 ++++++++++----------
contrib/docker/rhel7 | 2 +-
contrib/docker/rhel8 | 2 +-
contrib/docker/rhel9 | 2 +-
contrib/generate_gitlab_ci_yml.py | 2 +-
tests/qt_cmdagent_test.py | 2 +-
tests/qt_manifestmodel_test.py | 2 +-
tests/qt_repoagent_test.py | 2 +-
tests/qt_repomanager_test.py | 2 +-
tests/widget/repofilterbar_branch_test.py | 2 +-
tests/widget/sync_save_dialog_test.py | 2 +-
11 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b9c4e6a..2edb41c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -5,7 +5,7 @@ tests-hg-5.9:
script:
- apt-get update
- apt-get -y install python3-pyqt5 python3-pyqt5.qsci xvfb
- - pip3 install --user nose mock
+ - pip3 install --user nose
- hg -R /ci/repos/mercurial pull
- hg -R /ci/repos/mercurial update 'tag("re:\A5\.9")'
- hg -R /ci/repos/mercurial summary
@@ -19,7 +19,7 @@ tests-hg-6.0:
script:
- apt-get update
- apt-get -y install python3-pyqt5 python3-pyqt5.qsci xvfb
- - pip3 install --user nose mock
+ - pip3 install --user nose
- hg -R /ci/repos/mercurial pull
- hg -R /ci/repos/mercurial update 'tag("re:\A6\.0")'
- hg -R /ci/repos/mercurial summary
@@ -33,7 +33,7 @@ tests-hg-6.1:
script:
- apt-get update
- apt-get -y install python3-pyqt5 python3-pyqt5.qsci xvfb
- - pip3 install --user nose mock
+ - pip3 install --user nose
- hg -R /ci/repos/mercurial pull
- hg -R /ci/repos/mercurial update 'tag("re:\A6\.1")'
- hg -R /ci/repos/mercurial summary
@@ -47,7 +47,7 @@ tests-hg-6.2:
script:
- apt-get update
- apt-get -y install python3-pyqt5 python3-pyqt5.qsci xvfb
- - pip3 install --user nose mock
+ - pip3 install --user nose
- hg -R /ci/repos/mercurial pull
- hg -R /ci/repos/mercurial update 'tag("re:\A6\.2")'
- hg -R /ci/repos/mercurial summary
@@ -61,7 +61,7 @@ tests-hg-6.3:
script:
- apt-get update
- apt-get -y install python3-pyqt5 python3-pyqt5.qsci xvfb
- - pip3 install --user nose mock
+ - pip3 install --user nose
- hg -R /ci/repos/mercurial pull
- hg -R /ci/repos/mercurial update 'tag("re:\A6\.3")'
- hg -R /ci/repos/mercurial summary
@@ -75,7 +75,7 @@ tests-hg-6.4:
script:
- apt-get update
- apt-get -y install python3-pyqt5 python3-pyqt5.qsci xvfb
- - pip3 install --user nose mock
+ - pip3 install --user nose
- hg -R /ci/repos/mercurial pull
- hg -R /ci/repos/mercurial update 'tag("re:\A6\.4")'
- hg -R /ci/repos/mercurial summary
@@ -89,7 +89,7 @@ tests-hg-6.5:
script:
- apt-get update
- apt-get -y install python3-pyqt5 python3-pyqt5.qsci xvfb
- - pip3 install --user nose mock
+ - pip3 install --user nose
- hg -R /ci/repos/mercurial pull
- hg -R /ci/repos/mercurial update 'tag("re:\A6\.5")'
- hg -R /ci/repos/mercurial summary
@@ -103,7 +103,7 @@ tests-hg-6.6:
script:
- apt-get update
- apt-get -y install python3-pyqt5 python3-pyqt5.qsci xvfb
- - pip3 install --user nose mock
+ - pip3 install --user nose
- hg -R /ci/repos/mercurial pull
- hg -R /ci/repos/mercurial update 'tag("re:\A6\.6")'
- hg -R /ci/repos/mercurial summary
@@ -117,7 +117,7 @@ tests-hg-stable:
script:
- apt-get update
- apt-get -y install python3-pyqt5 python3-pyqt5.qsci xvfb
- - pip3 install --user nose mock
+ - pip3 install --user nose
- hg -R /ci/repos/mercurial pull
- hg -R /ci/repos/mercurial update stable
- hg -R /ci/repos/mercurial summary
@@ -131,7 +131,7 @@ tests-hg-default:
script:
- apt-get update
- apt-get -y install python3-pyqt5 python3-pyqt5.qsci xvfb
- - pip3 install --user nose mock
+ - pip3 install --user nose
- hg -R /ci/repos/mercurial pull
- hg -R /ci/repos/mercurial update default
- hg -R /ci/repos/mercurial summary
diff --git a/contrib/docker/rhel7 b/contrib/docker/rhel7
index 38b9591..e11eb40 100644
--- a/contrib/docker/rhel7
+++ b/contrib/docker/rhel7
@@ -21,7 +21,7 @@ RUN yum install -y \

# THg tests dependencies
RUN yum install -y python-pip && \
- pip install mock nose
+ pip install nose

# RPM build dependencies
RUN yum install -y \
diff --git a/contrib/docker/rhel8 b/contrib/docker/rhel8
index b615616..d6ee961 100644
--- a/contrib/docker/rhel8
+++ b/contrib/docker/rhel8
@@ -28,7 +28,7 @@ RUN yum install -y \

# THg tests dependencies
RUN yum install -y python3-pip && \
- pip3 install mock nose
+ pip3 install nose

# RPM build dependencies
RUN yum install -y \
diff --git a/contrib/docker/rhel9 b/contrib/docker/rhel9
index d65a214..7c745ef 100644
--- a/contrib/docker/rhel9
+++ b/contrib/docker/rhel9
@@ -23,7 +23,7 @@ RUN yum install -y \

# THg tests dependencies
RUN yum install -y python3-pip && \
- pip3 install mock nose
+ pip3 install nose

# Qscintilla
RUN pip3 install QScintilla
diff --git a/contrib/generate_gitlab_ci_yml.py b/contrib/generate_gitlab_ci_yml.py
index 6d2c60b..5efef52 100755
--- a/contrib/generate_gitlab_ci_yml.py
+++ b/contrib/generate_gitlab_ci_yml.py
@@ -81,7 +81,7 @@ def gen_gitlab_ci_yml():
'image': docker_image_name(hgver, prebuilt_images),
'script': [
*gen_install_apt_dependencies(extra=['xvfb']),
- f'pip3 install --user nose mock',
+ f'pip3 install --user nose',
*gen_ensure_mercurial_build(hgver, prebuilt_images),
thg_make_command('local'),
'xvfb-run ' + thg_make_command('tests'),
diff --git a/tests/qt_cmdagent_test.py b/tests/qt_cmdagent_test.py
index b828b1b..54a9bc7 100644
--- a/tests/qt_cmdagent_test.py
+++ b/tests/qt_cmdagent_test.py
@@ -1,7 +1,7 @@


import binascii
-import mock
+from unittest import mock
import unittest

from mercurial import (
diff --git a/tests/qt_manifestmodel_test.py b/tests/qt_manifestmodel_test.py
index e8b5a86..de1844a 100644
--- a/tests/qt_manifestmodel_test.py
+++ b/tests/qt_manifestmodel_test.py
@@ -1,6 +1,6 @@


-import mock
+from unittest import mock
import os
import sys
import unittest
diff --git a/tests/qt_repoagent_test.py b/tests/qt_repoagent_test.py
index 4176c35..3dbd009 100644
--- a/tests/qt_repoagent_test.py
+++ b/tests/qt_repoagent_test.py
@@ -1,6 +1,6 @@


-import mock
+from unittest import mock
import os
import unittest

diff --git a/tests/qt_repomanager_test.py b/tests/qt_repomanager_test.py
index 51fb2cb..07ea6b7 100644
--- a/tests/qt_repomanager_test.py
+++ b/tests/qt_repomanager_test.py
@@ -1,6 +1,6 @@


-import mock
+from unittest import mock
import os
import unittest

diff --git a/tests/widget/repofilterbar_branch_test.py b/tests/widget/repofilterbar_branch_test.py
index f7a0e54..4482cb6 100644
--- a/tests/widget/repofilterbar_branch_test.py
+++ b/tests/widget/repofilterbar_branch_test.py
@@ -1,6 +1,6 @@


-import mock
+from unittest import mock
import os
import unittest

diff --git a/tests/widget/sync_save_dialog_test.py b/tests/widget/sync_save_dialog_test.py
index c2a0619..7349668 100644
--- a/tests/widget/sync_save_dialog_test.py
+++ b/tests/widget/sync_save_dialog_test.py
@@ -1,6 +1,6 @@


-import mock
+from unittest import mock
import unittest

from tortoisehg.hgqt import (
--
2.41.0

Matt Harbison

unread,
Dec 4, 2023, 12:10:53 AM12/4/23
to TortoiseHg Developers
On Sunday, December 3, 2023 at 7:13:41 PM UTC-5 Eli Schwartz wrote:
It was moved to the stdlib in python 3.3, and the PyPI version is a
backport for python versions less than 3.3.
---
.gitlab-ci.yml | 20 ++++++++++----------
contrib/docker/rhel7 | 2 +-
contrib/docker/rhel8 | 2 +-
contrib/docker/rhel9 | 2 +-
contrib/generate_gitlab_ci_yml.py | 2 +-
tests/qt_cmdagent_test.py | 2 +-
tests/qt_manifestmodel_test.py | 2 +-
tests/qt_repoagent_test.py | 2 +-
tests/qt_repomanager_test.py | 2 +-
tests/widget/repofilterbar_branch_test.py | 2 +-
tests/widget/sync_save_dialog_test.py | 2 +-
11 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b9c4e6a..2edb41c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml

This file is generated, so changes need to be made to contrib/generate_gitlab_ci_yml.py for them to be persistent.

Also, why is all of the `apt-get` and repo manipulation removed?

Yuya Nishihara

unread,
Dec 4, 2023, 4:04:35 AM12/4/23
to 'Matt Harbison' via TortoiseHg Developers
On Sun, 3 Dec 2023 21:10:53 -0800 (PST), 'Matt Harbison' via TortoiseHg Developers wrote:
> This file is generated, so changes need to be made to
> contrib/generate_gitlab_ci_yml.py for them to be persistent.

I checked contrib/generate_gitlab_ci_yml.py generates the identical file.
Let me know if the command is wrong.

% PYTHONPATH=`pwd` ./contrib/generate_gitlab_ci_yml.py > .gitlab-ci.yml

> Also, why is all of the `apt-get` and repo manipulation removed?

Perhaps, it's messed up by google groups UI. The patch content looks good.

Yuya Nishihara

unread,
Dec 4, 2023, 4:04:37 AM12/4/23
to Eli Schwartz, thg...@googlegroups.com
On Sun, 3 Dec 2023 18:27:10 -0500, Eli Schwartz wrote:
> It was moved to the stdlib in python 3.3, and the PyPI version is a
> backport for python versions less than 3.3.

Queued for stable, thanks.

Matt Harbison

unread,
Dec 4, 2023, 10:09:41 AM12/4/23
to TortoiseHg Developers
Yep, it's the fact that the context lines start with "  -", but google groups un-idented them.

That command is correct.  Somehow I missed generate_gitlab_ci_yml.py in the file list.  Everything looks good here.

Eli Schwartz

unread,
Dec 4, 2023, 11:06:36 AM12/4/23
to thg...@googlegroups.com
On 12/4/23 12:10 AM, 'Matt Harbison' via TortoiseHg Developers wrote:
> This file is generated, so changes need to be made to
> contrib/generate_gitlab_ci_yml.py for them to be persistent.


I did -- that was one of the files I modified.


> Also, why is all of the `apt-get` and repo manipulation removed?


Please double-check. Those files are yaml, so each line starts with a
"-" character, but they are not in the `diff` format's leftmost column
(added/removed lines column). Only the pip lines modifying the use of
"mock" are in the leftmost column.


--
Eli Schwartz

Eli Schwartz

unread,
Dec 4, 2023, 11:06:48 AM12/4/23
to thg...@googlegroups.com
In case it helps to view the patch with a unified diff viewer that's a
bit more capable than Google Groups, I uploaded it to:

https://git.sr.ht/~eschwartz/thg


--
Eli Schwartz

Matt Harbison

unread,
Dec 4, 2023, 8:51:02 PM12/4/23
to TortoiseHg Developers
Yep, it's good- sorry about that.  I never figured out how to load a diff from google groups (importing doesn't work because they mangle the content), so I was just eyeballing it (and forgot about the mangling).
 

Eli Schwartz

unread,
Dec 4, 2023, 9:44:15 PM12/4/23
to thg...@googlegroups.com
On 12/4/23 8:51 PM, 'Matt Harbison' via TortoiseHg Developers wrote:
> Yep, it's good- sorry about that. I never figured out how to load a diff
> from google groups (importing doesn't work because they mangle the
> content), so I was just eyeballing it (and forgot about the mangling).


Yeah, generally I'd say it's a bit better to go with FOSS-operated
mailing lists as there's much greater guarantee it will be robust. I
thought mercurial itself ran one...

https://lists.sr.ht also exists, FWIW. (sr.ht isn't just a git host. In
fact it even has mercurial hosting.)


--
Eli Schwartz

Reply all
Reply to author
Forward
0 new messages