[PATCH 2 of 7] hglib tests: migrate away from (unmaintained) nose

Mathias De Mare mathias.de_mare at nokia.com
Tue Mar 14 08:26:34 UTC 2023


# HG changeset patch
# User Mathias De Mare <mathias.de_mare at nokia.com>
# Date 1678291498 -3600
#      Wed Mar 08 17:04:58 2023 +0100
# Node ID f296ae7240cfa59936335bb7ce819c154ba1c89e
# Parent  2876df3b730bb565d4f64764dd900b2ddb47a19c
hglib tests: migrate away from (unmaintained) nose

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-PYTHON=python
+PYTHON=python3
 help:
 	@echo 'Commonly used make targets:'
 	@echo '  tests - run all tests in the automatic test suite'
@@ -14,4 +14,4 @@ dist: MANIFEST.in
 	TAR_OPTIONS="--owner=root --group=root --mode=u+w,go-w,a+rX-s" $(PYTHON) setup.py -q sdist
 
 tests:
-	$(PYTHON) test.py --with-doctest
+	$(PYTHON) -m unittest discover
diff --git a/test.py b/test.py
deleted file mode 100644
--- a/test.py
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env python
-
-import nose
-from tests import with_hg
-
-if __name__ == '__main__':
-    nose.main(addplugins=[with_hg.WithHgPlugin()])
diff --git a/tests/__init__.py b/tests/__init__.py
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,22 +0,0 @@
-import os, tempfile, sys, shutil
-
-def setUp():
-    os.environ['LANG'] = os.environ['LC_ALL'] = os.environ['LANGUAGE'] = 'C'
-    os.environ["EMAIL"] = "Foo Bar <foo.bar at example.com>"
-    os.environ['CDPATH'] = ''
-    os.environ['COLUMNS'] = '80'
-    os.environ['GREP_OPTIONS'] = ''
-    os.environ['http_proxy'] = ''
-
-    os.environ["HGEDITOR"] = sys.executable + ' -c "import sys; sys.exit(0)"'
-    os.environ["HGMERGE"] = "internal:merge"
-    os.environ["HGUSER"]   = "test"
-    os.environ["HGENCODING"] = "ascii"
-    os.environ["HGENCODINGMODE"] = "strict"
-    tmpdir = tempfile.mkdtemp('', 'python-hglib.')
-    os.environ["HGTMP"] = os.path.realpath(tmpdir)
-    os.environ["HGRCPATH"] = os.pathsep
-
-def tearDown(self):
-    os.chdir('..')
-    shutil.rmtree(os.environ["HGTMP"])
diff --git a/tests/common.py b/tests/common.py
--- a/tests/common.py
+++ b/tests/common.py
@@ -14,6 +14,22 @@ def resultappender(list):
 
 class basetest(unittest.TestCase):
     def setUp(self):
+        os.environ['LANG'] = os.environ['LC_ALL'] = os.environ['LANGUAGE'] = 'C'
+        os.environ["EMAIL"] = "Foo Bar <foo.bar at example.com>"
+        os.environ['CDPATH'] = ''
+        os.environ['COLUMNS'] = '80'
+        os.environ['GREP_OPTIONS'] = ''
+        os.environ['http_proxy'] = ''
+
+        os.environ["HGEDITOR"] = sys.executable + ' -c "import sys; sys.exit(0)"'
+        os.environ["HGMERGE"] = "internal:merge"
+        os.environ["HGUSER"]   = "test"
+        os.environ["HGENCODING"] = "ascii"
+        os.environ["HGENCODINGMODE"] = "strict"
+        tmpdir = tempfile.mkdtemp('', 'python-hglib.')
+        os.environ["HGTMP"] = os.path.realpath(tmpdir)
+        os.environ["HGRCPATH"] = os.pathsep
+
         self._testtmp = os.environ["TESTTMP"] = os.environ["HOME"] = \
             os.path.join(os.environ["HGTMP"], self.__class__.__name__)
 
@@ -37,8 +53,9 @@ class basetest(unittest.TestCase):
             if client.server is not None:
                 client.close()
         os.chdir('..')
+
         try:
-            shutil.rmtree(self._testtmp)
+            shutil.rmtree(self._testtmp, ignore_errors=True)
         except AttributeError:
             pass # if our setUp was overriden
 
diff --git a/tests/test-annotate.py b/tests/test_annotate.py
rename from tests/test-annotate.py
rename to tests/test_annotate.py
diff --git a/tests/test-bookmarks.py b/tests/test_bookmarks.py
rename from tests/test-bookmarks.py
rename to tests/test_bookmarks.py
diff --git a/tests/test-branch.py b/tests/test_branch.py
rename from tests/test-branch.py
rename to tests/test_branch.py
diff --git a/tests/test-branches.py b/tests/test_branches.py
rename from tests/test-branches.py
rename to tests/test_branches.py
diff --git a/tests/test-bundle.py b/tests/test_bundle.py
rename from tests/test-bundle.py
rename to tests/test_bundle.py
diff --git a/tests/test-clone.py b/tests/test_clone.py
rename from tests/test-clone.py
rename to tests/test_clone.py
diff --git a/tests/test-commit.py b/tests/test_commit.py
rename from tests/test-commit.py
rename to tests/test_commit.py
diff --git a/tests/test-config.py b/tests/test_config.py
rename from tests/test-config.py
rename to tests/test_config.py
diff --git a/tests/test-context.py b/tests/test_context.py
rename from tests/test-context.py
rename to tests/test_context.py
diff --git a/tests/test-copy.py b/tests/test_copy.py
rename from tests/test-copy.py
rename to tests/test_copy.py
diff --git a/tests/test-diff.py b/tests/test_diff.py
rename from tests/test-diff.py
rename to tests/test_diff.py
diff --git a/tests/test-encoding.py b/tests/test_encoding.py
rename from tests/test-encoding.py
rename to tests/test_encoding.py
diff --git a/tests/test-forget.py b/tests/test_forget.py
rename from tests/test-forget.py
rename to tests/test_forget.py
diff --git a/tests/test-grep.py b/tests/test_grep.py
rename from tests/test-grep.py
rename to tests/test_grep.py
diff --git a/tests/test-heads.py b/tests/test_heads.py
rename from tests/test-heads.py
rename to tests/test_heads.py
diff --git a/tests/test-hglib.py b/tests/test_hglib.py
rename from tests/test-hglib.py
rename to tests/test_hglib.py
diff --git a/tests/test-hidden.py b/tests/test_hidden.py
rename from tests/test-hidden.py
rename to tests/test_hidden.py
diff --git a/tests/test-import.py b/tests/test_import.py
rename from tests/test-import.py
rename to tests/test_import.py
diff --git a/tests/test-init.py b/tests/test_init.py
rename from tests/test-init.py
rename to tests/test_init.py
diff --git a/tests/test-log.py b/tests/test_log.py
rename from tests/test-log.py
rename to tests/test_log.py
diff --git a/tests/test-manifest.py b/tests/test_manifest.py
rename from tests/test-manifest.py
rename to tests/test_manifest.py
diff --git a/tests/test-merge.py b/tests/test_merge.py
rename from tests/test-merge.py
rename to tests/test_merge.py
diff --git a/tests/test-move.py b/tests/test_move.py
rename from tests/test-move.py
rename to tests/test_move.py
diff --git a/tests/test-outgoing-incoming.py b/tests/test_outgoing_incoming.py
rename from tests/test-outgoing-incoming.py
rename to tests/test_outgoing_incoming.py
diff --git a/tests/test-parents.py b/tests/test_parents.py
rename from tests/test-parents.py
rename to tests/test_parents.py
diff --git a/tests/test-paths.py b/tests/test_paths.py
rename from tests/test-paths.py
rename to tests/test_paths.py
diff --git a/tests/test-phase.py b/tests/test_phase.py
rename from tests/test-phase.py
rename to tests/test_phase.py
diff --git a/tests/test-pull.py b/tests/test_pull.py
rename from tests/test-pull.py
rename to tests/test_pull.py
diff --git a/tests/test-push.py b/tests/test_push.py
rename from tests/test-push.py
rename to tests/test_push.py
diff --git a/tests/test-remove.py b/tests/test_remove.py
rename from tests/test-remove.py
rename to tests/test_remove.py
diff --git a/tests/test-resolve.py b/tests/test_resolve.py
rename from tests/test-resolve.py
rename to tests/test_resolve.py
diff --git a/tests/test-status.py b/tests/test_status.py
rename from tests/test-status.py
rename to tests/test_status.py
diff --git a/tests/test-summary.py b/tests/test_summary.py
rename from tests/test-summary.py
rename to tests/test_summary.py
diff --git a/tests/test-tags.py b/tests/test_tags.py
rename from tests/test-tags.py
rename to tests/test_tags.py
diff --git a/tests/test-update.py b/tests/test_update.py
rename from tests/test-update.py
rename to tests/test_update.py
diff --git a/tests/with_hg.py b/tests/with_hg.py
deleted file mode 100644
--- a/tests/with_hg.py
+++ /dev/null
@@ -1,33 +0,0 @@
-import os
-from nose.plugins import Plugin
-
-class WithHgPlugin(Plugin):
-    name = 'with-hg'
-    enabled = False
-
-    def options(self, parser, env):
-        Plugin.options(self, parser, env)
-        parser.add_option('--with-hg',
-                          action='store',
-                          type='string',
-                          metavar='HG',
-                          dest='with_hg',
-                          help='test using specified hg script.')
-
-    def configure(self, options, conf):
-        Plugin.configure(self, options, conf)
-        if options.with_hg:
-            self.enabled = True
-            self.hgpath = os.path.realpath(options.with_hg)
-
-    def begin(self):
-        import hglib
-
-        p = hglib.util.popen([self.hgpath, 'version'])
-        p.communicate()
-
-        if p.returncode:
-            raise ValueError("custom hg %r doesn't look like Mercurial"
-                             % self.hgpath)
-
-        hglib.HGPATH = self.hgpath



More information about the Mercurial-devel mailing list