port code from python2 to python3 17/289917/26
authorbiao716.wang <biao716.wang@samsung.com>
Wed, 15 Mar 2023 10:35:54 +0000 (19:35 +0900)
committerbiao716.wang <biao716.wang@samsung.com>
Wed, 22 Mar 2023 12:27:31 +0000 (21:27 +0900)
Change-Id: I4b8c51a7ba90e07fc8d558c69bd924a93fa8b908
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
67 files changed:
Makefile [new file with mode: 0644]
debian/compat
debian/control
debian/rules
doc/source/conf.py
examples/how_to/add_command.py
examples/how_to/create_a_job.py
examples/how_to/create_nested_views.py
examples/how_to/delete_all_the_nodes_except_master.py
examples/how_to/get_config.py
examples/how_to/get_plugin_information.py
examples/how_to/get_version_info_from_last_good_build.py
examples/how_to/query_a_build.py
examples/how_to/search_artifact_by_regexp.py
examples/how_to/search_artifacts.py
examples/low_level/copy_a_job.py
examples/low_level/create_a_view_low_level.py
examples/low_level/example_param_build.py
examples/low_level/login_with_auth.py
examples/low_level/post_watcher.py
jenkinsapi/api.py
jenkinsapi/jenkins.py
jenkinsapi/jenkinsbase.py
jenkinsapi/job.py
jenkinsapi/jobs.py
jenkinsapi/node.py
jenkinsapi/nodes.py
jenkinsapi/plugins.py
jenkinsapi/queue.py
jenkinsapi/result_set.py
jenkinsapi/utils/requester.py
jenkinsapi/view.py
jenkinsapi/views.py
jenkinsapi_tests/systests/base.py
jenkinsapi_tests/systests/test_downstream_upstream.py
jenkinsapi_tests/systests/test_invocation.py
jenkinsapi_tests/systests/test_jenkins.py
jenkinsapi_tests/systests/test_jenkins_matrix.py
jenkinsapi_tests/systests/test_nodes.py
jenkinsapi_tests/systests/test_parameterized_builds.py
jenkinsapi_tests/systests/test_queue.py
jenkinsapi_tests/systests/test_views.py
jenkinsapi_tests/test_utils/random_strings.py
jenkinsapi_tests/unittests/test_build.py
jenkinsapi_tests/unittests/test_build_scm_git.py
jenkinsapi_tests/unittests/test_executors.py
jenkinsapi_tests/unittests/test_fingerprint.py
jenkinsapi_tests/unittests/test_jenkins.py
jenkinsapi_tests/unittests/test_job.py
jenkinsapi_tests/unittests/test_job_folders.py
jenkinsapi_tests/unittests/test_job_get_all_builds.py
jenkinsapi_tests/unittests/test_job_maven.py
jenkinsapi_tests/unittests/test_job_scm_hg.py
jenkinsapi_tests/unittests/test_node.py
jenkinsapi_tests/unittests/test_nodes.py
jenkinsapi_tests/unittests/test_plugins.py
jenkinsapi_tests/unittests/test_queue.py
jenkinsapi_tests/unittests/test_requester.py
jenkinsapi_tests/unittests/test_result_set.py
jenkinsapi_tests/unittests/test_view.py
jenkinsapi_tests/unittests/test_views.py
jenkinsapi_utils/jenkins_launcher.py
jenkinsapi_utils/simple_post_logger.py
release.sh
requirements.txt [new file with mode: 0644]
setup.cfg
setup.py

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..d664d05
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,5 @@
+.PHONY: install
+
+install:
+       python3 setup.py install --prefix=${DESTDIR}/usr
+
index 7f8f011eb73d6043d2e6db9d2c101195ae2801f2..f599e28b8ab0d8c9c57a486c89c4a5132dcbd3b2 100644 (file)
@@ -1 +1 @@
-7
+10
index e92d293a2b8b59fe89619b59dc842cb36526e928..e8bdb0bac6e9f9e4a3426cb942b5aa4842dd9edd 100644 (file)
@@ -2,17 +2,18 @@ Source: python-jenkinsapi
 Section: python
 Priority: optional
 Maintainer: Al Stone <ahs3@debian.org>
-Build-Depends: debhelper (>= 8.0.0), dh-python, python-dev, python-all-dev, python-lxml, python-setuptools
+Build-Depends: debhelper (>= 8.0.0), dh-python, python3, python3-all-dev, python3-lxml, python3-setuptools,
+ python3-pbr, python3-pytest, python3-pylint-common, python3-mock
 XS-Python-Version: current
 Standards-Version: 3.9.5
 Homepage: http://pypi.python.org/pypi/jenkinsapi
 
-Package: python-jenkinsapi
+Package: python3-jenkinsapi
 Architecture: all
-Depends: python-lxml, python-bs4, python-pkg-resources, python-requests,
- ${python:Depends}, ${misc:Depends}
-Provides: ${python:Provides}
-XB-Python-Versions: ${python:Versions}
+Depends: python3-lxml, python3-bs4, python3-pkg-resources, python3-requests,
+ ${python3:Depends}, ${misc:Depends}
+Provides: ${python3:Provides}
+XB-Python-Versions: ${python3:Versions}
 Description: bindings for Python usage of the Jenkins remote API
  Jenkins is the market leading continuous integration system, originally
  created by Kohsuke Kawaguchi. This API makes Jenkins even easier to use
index 2ebce130e5cbe9b461322403fa00af29ad42902e..1232503e741a2e5e24df5dc56bbf67a8866fea42 100755 (executable)
@@ -10,4 +10,9 @@
 #export DH_VERBOSE=1
 
 %:
-       dh $@ --with python2
+       dh $@ --with python3 --buildsystem=pybuild
+
+override_dh_auto_test:
+       #disable test
+
+
index 336c8f10991ab89e23c36566a92f6aaca1d9ee1a..4596be804bbb210991d1b5b6c54b1e87f0cc87b6 100644 (file)
@@ -52,8 +52,8 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = u' JenkinsAPI'
-copyright = u'2012, %s' % PROJECT_AUTHORS
+project = ' JenkinsAPI'
+copyright = '2012, %s' % PROJECT_AUTHORS
 
 # The version info for the project you're documenting, acts as replacement for
 # built documents.
@@ -194,7 +194,7 @@ latex_elements = {
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, documentclass [howto/manual]).
 latex_documents = [
-    ('index', 'JenkinsAPI.tex', u'JenkinsAPI Documentation', u'xxx', 'manual'),
+    ('index', 'JenkinsAPI.tex', 'JenkinsAPI Documentation', 'xxx', 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
@@ -223,7 +223,7 @@ latex_documents = [
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
-    ('index', 'jenkinsapi', u' JenkinsAPI Documentation', [u'xxx'], 1)
+    ('index', 'jenkinsapi', ' JenkinsAPI Documentation', ['xxx'], 1)
 ]
 
 # If true, show URL addresses after external links.
@@ -236,8 +236,8 @@ man_pages = [
 # (source start file, target name, title, author,
 #  dir menu entry, description, category)
 texinfo_documents = [
-    ('index', 'JenkinsAPI', u'JenkinsAPI Documentation',
-     u'xxx', 'JenkinsAPI', 'One line description of project.',
+    ('index', 'JenkinsAPI', 'JenkinsAPI Documentation',
+     'xxx', 'JenkinsAPI', 'One line description of project.',
      'Miscellaneous'),
 ]
 
index fadfa027a919ac5814654b182291589048d3fd15..40ec3247e82c4b854b40efb8ac67084b84df9ffb 100644 (file)
@@ -33,7 +33,7 @@ shell = ET.SubElement(builders, 'hudson.tasks.Shell')
 command = ET.SubElement(shell, 'command')
 command.text = "ls"
 
-print ET.tostring(root)
+print(ET.tostring(root))
 J[jobname].update_config(ET.tostring(root))
 
 #J.delete_job(jobname)
index 343685ed942f048557072823def8e337f4e1e551..3fd8bc84d0d34b93d576d9fa88b0c797be05562c 100644 (file)
@@ -1,4 +1,4 @@
-from __future__ import print_function
+
 
 import logging
 logging.basicConfig()
index b82b28d7bba6df6f705b241f881f03254d4e4c3d..2ce5b1aa9d3cab65294efdabed5a0a1861ead8d8 100644 (file)
@@ -1,6 +1,6 @@
 # This example requires NestedViews plugin to be installed in Jenkins
 # You need to have at least one job in your Jenkins to see views
-from __future__ import print_function
+
 
 import logging
 from pkg_resources import resource_string
@@ -29,7 +29,7 @@ if top_view is None:
 else:
     logger.info('View has been created')
 
-print('top_view.views=', top_view.views.keys())
+print('top_view.views=', list(top_view.views.keys()))
 logger.info('Attempting to create view inside nested view')
 sub_view = top_view.views.create('SubView')
 if sub_view is None:
index e68c89aeedcff8fa275dc0e97f631431c4e45d65..cee05a3cdaeefa64337321f9f0042f66c3dce4f1 100644 (file)
@@ -5,7 +5,7 @@ from jenkinsapi.jenkins import Jenkins
 
 j = Jenkins('http://localhost:8080')
 
-for node_id, _ in j.get_nodes().iteritems():
+for node_id, _ in j.get_nodes().items():
     if not node_id == 'master':
         print(node_id)
         j.delete_node(node_id)
index 72b66359b20704bcd9fbf9a8fd157c0009f64bfb..51e9267f0b22512ed69f43a1f8bebe26bf298cae 100644 (file)
@@ -1,7 +1,7 @@
 """
 An example of how to use JenkinsAPI to fetch the config XML of a job.
 """
-from __future__ import print_function
+
 
 from jenkinsapi.jenkins import Jenkins
 J = Jenkins('http://localhost:8080')
index 380c946fed6f680d70f118e515ff193038d1ce65..42914c82e6ca9f4fba8e1e87267fa88795f16973 100644 (file)
@@ -1,7 +1,7 @@
 """
 Get information about currently installed plugins
 """
-from __future__ import print_function
+
 
 from jenkinsapi.jenkins import Jenkins
 
index 3df5f559737e8c3b3e63db76d0e0bc7d2ef506e9..07da7bc4e5de75edcb1c726d325c2bcce64034e8 100644 (file)
@@ -1,7 +1,7 @@
 """
 Extract version information from the latest build.
 """
-from __future__ import print_function
+
 
 from jenkinsapi.jenkins import Jenkins
 
index 16dc56900b52a0a5a3d8632ef91ec17ca2579084..b6dd9d1b85b9597ab5bb0de147a488a3404e7bec 100644 (file)
@@ -1,10 +1,10 @@
-from __future__ import print_function
+
 
 from jenkinsapi.view import View
 from jenkinsapi.jenkins import Jenkins
 
 J = Jenkins('http://localhost:8080')
-print(J.items())
+print(list(J.items()))
 j = J['foo']
 j = J.get_job("foo")
 b = j.get_last_build()
index 7f73562651a5f13c18bcdb006529bf3577dee990..7f738980cc84bbe9407a1487978a622b579bf083 100644 (file)
@@ -1,4 +1,4 @@
-from __future__ import print_function
+
 
 from jenkinsapi.api import search_artifact_by_regexp
 import re
index 31d19c6276546935444e6dbe40077663f17f395d..f41388de10bdcebbf3e15579cb41b63e138bf72a 100644 (file)
@@ -1,4 +1,4 @@
-from __future__ import print_function
+
 
 from jenkinsapi.api import search_artifacts
 
index ae0399b138ffd3831c7f1ab6c9b4add0b9e5c4e9..9594f953ab72dd20d5b951dfa59da6d25d131e2c 100644 (file)
@@ -1,7 +1,7 @@
 """
 A lower-level implementation of copying a job in Jenkins
 """
-from __future__ import print_function
+
 
 import requests
 from jenkinsapi.jenkins import Jenkins
index 21115ca31f4bdefecd667f7830fc7d15160c60de..39fe015ac6ab32b077d6283162e2e664ce6841f2 100644 (file)
@@ -2,7 +2,7 @@
 A low level example:
 This is how JenkinsAPI creates views
 """
-from __future__ import print_function
+
 
 import requests
 import json
index d6e8c3328c13a023c94b369055ed181751150256..a34ee72b9c61541c605d59ff8cae455f549e2f9c 100644 (file)
@@ -1,4 +1,4 @@
-from __future__ import print_function
+
 
 import json
 import requests
index c11aa9f2cb48d0e08b58f8f741acf64ec4aa9e59..40e8942bed82e7124996a1de173faa0b5bc4ba05 100644 (file)
@@ -1,7 +1,7 @@
 """
 A lower level example of how we login with authentication
 """
-from __future__ import print_function
+
 
 from jenkinsapi import jenkins
 
@@ -9,4 +9,4 @@ from jenkinsapi import jenkins
 J = jenkins.Jenkins("http://localhost:8080", username="sal", password="foobar")
 J.poll()
 
-print(J.items())
+print(list(J.items()))
index c6921fdbd4bab72a4d7b46ac07f16770c49c6153..da4ff6306d39d7e8f45d766af339ba25aee13dc8 100644 (file)
@@ -12,8 +12,8 @@ You can use this to test GET and POST methods.
 
 """
 
-import SimpleHTTPServer
-import SocketServer
+import http.server
+import socketserver
 import logging
 import cgi
 
@@ -25,12 +25,12 @@ PORT = 8080
 I = "localhost"
 
 
-class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
+class ServerHandler(http.server.SimpleHTTPRequestHandler):
 
     def do_GET(self):
         logging.warning("======= GET STARTED =======")
         logging.warning(self.headers)
-        SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
+        http.server.SimpleHTTPRequestHandler.do_GET(self)
 
     def do_POST(self):
         logging.warning("======= POST STARTED =======")
@@ -45,11 +45,11 @@ class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
         for item in form.list:
             logging.warning(item)
         logging.warning("\n")
-        SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
+        http.server.SimpleHTTPRequestHandler.do_GET(self)
 
 Handler = ServerHandler
 
-httpd = SocketServer.TCPServer(("", PORT), Handler)
+httpd = socketserver.TCPServer(("", PORT), Handler)
 
-print "Serving at: http://%(interface)s:%(port)s" % dict(interface=I or "localhost", port=PORT)
+print("Serving at: http://%(interface)s:%(port)s" % dict(interface=I or "localhost", port=PORT))
 httpd.serve_forever()
\ No newline at end of file
index c191907136db774fa6ca80f802f9f7d52f96fc70..be4a77735c4c335205a2a0d0a6a6f7535d725e3d 100644 (file)
@@ -77,7 +77,7 @@ def get_artifacts(jenkinsurl, jobid=None, build_no=None,
         build = job.get_last_good_build()
     artifacts = build.get_artifact_dict()
     log.info(msg="Found %i artifacts in '%s'"
-             % (len(artifacts.keys()), build_no))
+             % (len(list(artifacts.keys())), build_no))
     return artifacts
 
 
@@ -175,7 +175,7 @@ def install_artifacts(artifacts, dirstruct, installdir, basestaticurl):
     """
     assert basestaticurl.endswith("/"), "Basestaticurl should end with /"
     installed = []
-    for reldir, artifactnames in dirstruct.items():
+    for reldir, artifactnames in list(dirstruct.items()):
         destdir = os.path.join(installdir, reldir)
         if not os.path.exists(destdir):
             log.warn(msg="Making install directory %s" % destdir)
@@ -184,7 +184,7 @@ def install_artifacts(artifacts, dirstruct, installdir, basestaticurl):
             assert os.path.isdir(destdir)
         for artifactname in artifactnames:
             destpath = os.path.abspath(os.path.join(destdir, artifactname))
-            if artifactname in artifacts.keys():
+            if artifactname in list(artifacts.keys()):
                 # The artifact must be loaded from jenkins
                 theartifact = artifacts[artifactname]
             else:
@@ -222,10 +222,10 @@ def search_artifact_by_regexp(jenkinsurl, jobid, artifactRegExp,
         artifacts = build.get_artifact_dict()
 
         try:
-            it = artifacts.iteritems()
+            it = iter(artifacts.items())
         except AttributeError:
             # Python3
-            it = artifacts.items()
+            it = list(artifacts.items())
 
         for name, art in it:
             md_match = artifactRegExp.search(name)
index d0708f507f767c9fda225d2e1dbc6a675068255c..6d0295df90f1787e468b5dbaf1abb5c2800c73f8 100644 (file)
@@ -6,8 +6,8 @@ Module for jenkinsapi Jenkins object
 import json
 
 try:
-    import urlparse
-    from urllib import quote as urlquote, urlencode
+    import urllib.parse
+    from urllib.parse import quote as urlquote, urlencode
 except ImportError:
     # Python3
     import urllib.parse as urlparse
@@ -194,7 +194,7 @@ class Jenkins(JenkinsBase):
         return list(self.get_jobs())
 
     def keys(self):
-        return [a for a in self.iterkeys()]
+        return [a for a in self.keys()]
 
     # This is a function alias we retain for historical compatibility
     get_jobs_list = keys
@@ -252,7 +252,7 @@ class Jenkins(JenkinsBase):
 
     def get_node_url(self, nodename=""):
         """Return the url for nodes"""
-        url = urlparse.urljoin(self.base_server_url(), 'computer/%s' % urlquote(nodename))
+        url = urllib.parse.urljoin(self.base_server_url(), 'computer/%s' % urlquote(nodename))
         return url
 
     def get_queue_url(self):
index d7d23a6eb7b06331841ed7ef4078b912e9ce44aa..b17ed1245e5474d2116431f94c005401c379469a 100644 (file)
@@ -92,7 +92,7 @@ class JenkinsBase(object):
 
     def resolve_job_folders(self, jobs):
         for job in list(jobs):
-            if 'color' not in job.keys():
+            if 'color' not in list(job.keys()):
                 jobs.remove(job)
                 jobs += self.process_job_folder(job)
 
@@ -103,7 +103,7 @@ class JenkinsBase(object):
         result = []
 
         for job in data.get('jobs', []):
-            if 'color' not in job.keys():
+            if 'color' not in list(job.keys()):
                 result += self.process_job_folder(job)
             else:
                 result.append(job)
index ff6122dae6933525f31fc3cece62423e373f86c3..dc48376c102619f7fb2c19024f70504697080d40 100644 (file)
@@ -23,7 +23,7 @@ import xml.etree.ElementTree as ET
 
 
 try:
-    import urlparse
+    import urllib.parse
 except ImportError:
     # Python3
     import urllib.parse as urlparse
@@ -157,7 +157,7 @@ class Job(JenkinsBase, MutableJenkinsThing):
         out = {'parameter': build_p}
         if file_params:
             file_p = [{'name': k, 'file': k}
-                      for k in file_params.keys()]
+                      for k in list(file_params.keys())]
             out['parameter'].extend(file_p)
 
         if len(out['parameter']) == 1:
@@ -187,7 +187,7 @@ class Job(JenkinsBase, MutableJenkinsThing):
 
         # Either copy the params dict or make a new one.
         build_params = build_params and dict(
-            build_params.items()) or {}  # Via POSTed JSON
+            list(build_params.items())) or {}  # Via POSTed JSON
 
         url = self.get_build_triggerurl(files)
         if cause:
@@ -513,7 +513,7 @@ class Job(JenkinsBase, MutableJenkinsThing):
         """
         url = self.get_config_xml_url()
         try:
-            if isinstance(config, unicode):  # pylint: disable=undefined-variable
+            if isinstance(config, str):  # pylint: disable=undefined-variable
                 config = str(config)
         except NameError:
             # Python3 already a str
@@ -598,7 +598,7 @@ class Job(JenkinsBase, MutableJenkinsThing):
         if not self.is_queued():
             raise NotInQueue()
         queue_id = self._data['queueItem']['id']
-        url = urlparse.urljoin(self.get_jenkins_obj().get_queue().baseurl,
+        url = urllib.parse.urljoin(self.get_jenkins_obj().get_queue().baseurl,
                                'cancelItem?id=%s' % queue_id)
         self.get_jenkins_obj().requester.post_and_confirm_status(url, data='')
         return True
index eda5e7c1f484bd81c89d0d4cdaf9653803e3dd2d..46c091ee083b02e5d17fa8e33079c09e226f27d9 100644 (file)
@@ -77,7 +77,7 @@ class Jobs(object):
         """
         True if job_name is the name of a defined job
         """
-        return job_name in self.keys()
+        return job_name in list(self.keys())
 
     def iterkeys(self):
         """
@@ -90,7 +90,7 @@ class Jobs(object):
         """
         Return a list of the names of all jobs
         """
-        return list(self.iterkeys())
+        return list(self.keys())
 
     def create(self, job_name, config):
         """
@@ -104,7 +104,7 @@ class Jobs(object):
 
         params = {'name': job_name}
         try:
-            if isinstance(config, unicode):  # pylint: disable=undefined-variable
+            if isinstance(config, str):  # pylint: disable=undefined-variable
                 config = str(config)
         except NameError:
             # Python3 already a str
index 75a6e46c1f049f142ab6894efdd97ac3d64c8f26..8acd6d4c7f8452fde1e6f87a68eebbffe87c1742 100644 (file)
@@ -7,7 +7,7 @@ from jenkinsapi.custom_exceptions import PostRequired
 import logging
 
 try:
-    from urllib import quote as urlquote
+    from urllib.parse import quote as urlquote
 except ImportError:
     # Python3
     from urllib.parse import quote as urlquote
index a3bd036c0d27581f5504790154a8bcfa390ab612..0f5ce75f5b249fef07910219f2d89d85fe089c5e 100644 (file)
@@ -29,14 +29,14 @@ class Nodes(JenkinsBase):
         return 'Nodes @ %s' % self.baseurl
 
     def __contains__(self, node_name):
-        return node_name in self.keys()
+        return node_name in list(self.keys())
 
     def iterkeys(self):
         for item in self._data['computer']:
             yield item['displayName']
 
     def keys(self):
-        return list(self.iterkeys())
+        return list(self.keys())
 
     def iteritems(self):
         for item in self._data['computer']:
@@ -48,11 +48,11 @@ class Nodes(JenkinsBase):
             yield item['displayName'], Node(nodeurl, nodename, self.jenkins)
 
     def __getitem__(self, nodename):
-        self_as_dict = dict(self.iteritems())
+        self_as_dict = dict(iter(self.items()))
         if nodename in self_as_dict:
             return self_as_dict[nodename]
         else:
             raise UnknownNode(nodename)
 
     def __len__(self):
-        return len(self.iteritems())
+        return len(iter(self.items()))
index a1cc8be404e4b38bb64221530439d45ec14057a0..0a9e80e0aff084b7c0839ce56b7a531ef20a906a 100644 (file)
@@ -1,7 +1,7 @@
 """
 jenkinsapi plugins
 """
-from __future__ import print_function
+
 
 import logging
 from jenkinsapi.plugin import Plugin
@@ -28,7 +28,7 @@ class Plugins(JenkinsBase):
         return self.get_data(self.baseurl, tree=tree)
 
     def keys(self):
-        return self.get_plugins_dict().keys()
+        return list(self.get_plugins_dict().keys())
 
     __iter__ = keys
 
@@ -36,7 +36,7 @@ class Plugins(JenkinsBase):
         return self._get_plugins()
 
     def values(self):
-        return [a[1] for a in self.iteritems()]
+        return [a[1] for a in self.items()]
 
     def _get_plugins(self):
         if 'plugins' in self._data:
@@ -47,7 +47,7 @@ class Plugins(JenkinsBase):
         return dict(self._get_plugins())
 
     def __len__(self):
-        return len(self.get_plugins_dict().keys())
+        return len(list(self.get_plugins_dict().keys()))
 
     def __getitem__(self, plugin_name):
         try:
@@ -59,7 +59,7 @@ class Plugins(JenkinsBase):
         """
         True if plugin_name is the name of a defined plugin
         """
-        return plugin_name in self.keys()
+        return plugin_name in list(self.keys())
 
     def __str__(self):
         plugins = [plugin["shortName"] for plugin in self._data.get("plugins", [])]
index 08049279be27348a3871dc70a3be7983acc64070..5b51ca925aa21c44dfbf9e2fd804fb0e30537914 100644 (file)
@@ -46,16 +46,16 @@ class Queue(JenkinsBase):
             yield QueueItem(self.jenkins, **item)
 
     def keys(self):
-        return list(self.iterkeys())
+        return list(self.keys())
 
     def values(self):
-        return list(self.itervalues())
+        return list(self.values())
 
     def __len__(self):
         return len(self._data['items'])
 
     def __getitem__(self, item_id):
-        self_as_dict = dict(self.iteritems())
+        self_as_dict = dict(iter(self.items()))
         if item_id in self_as_dict:
             return self_as_dict[item_id]
         else:
index 6962c0778a13643ea12eba8815c4c3910af25c48..569988c47298aae1da84e36910636e9ea137a794 100644 (file)
@@ -30,10 +30,10 @@ class ResultSet(JenkinsBase):
         return str(self)
 
     def keys(self):
-        return [a[0] for a in self.iteritems()]
+        return [a[0] for a in self.items()]
 
     def items(self):
-        return [a for a in self.iteritems()]
+        return [a for a in self.items()]
 
     def iteritems(self):
         for suite in self._data.get("suites", []):
@@ -49,8 +49,8 @@ class ResultSet(JenkinsBase):
                         yield result.identifier(), result
 
     def __len__(self):
-        return len(self.items())
+        return len(list(self.items()))
 
     def __getitem__(self, key):
-        self_as_dict = dict(self.iteritems())
+        self_as_dict = dict(iter(self.items()))
         return self_as_dict[key]
index c96678662d17555a120eab2f6f91c34c28d49875..4113a6d629d708653dbf3993a7173e0901b116a4 100644 (file)
@@ -5,7 +5,7 @@ Module for jenkinsapi requester (which is a wrapper around python-requests)
 import requests
 
 try:
-    import urlparse
+    import urllib.parse
 except ImportError:
     # Python3
     import urllib.parse as urlparse
@@ -41,7 +41,7 @@ class Requester(object):
         if username:
             assert password, 'Cannot set a username without a password!'
 
-        self.base_scheme = urlparse.urlsplit(baseurl).scheme if baseurl else None
+        self.base_scheme = urllib.parse.urlsplit(baseurl).scheme if baseurl else None
         self.username = username
         self.password = password
         self.ssl_verify = ssl_verify
@@ -78,8 +78,8 @@ class Requester(object):
         Updates scheme of given url to the one used in Jenkins baseurl.
         """
         if self.base_scheme and not url.startswith("%s://" % self.base_scheme):
-            url_split = urlparse.urlsplit(url)
-            url = urlparse.urlunsplit(
+            url_split = urllib.parse.urlsplit(url)
+            url = urllib.parse.urlunsplit(
                 [
                     self.base_scheme,
                     url_split.netloc,
index c2628040a4396aa355a64ca0ae1ab833cfefc647..f2a5c9118a48dcc914d4efddfba0a240417dfa06 100644 (file)
@@ -2,7 +2,7 @@
 Module for jenkinsapi views
 """
 try:
-    from urllib import urlencode
+    from urllib.parse import urlencode
 except ImportError:
     # Python3
     from urllib.parse import urlencode
@@ -40,7 +40,7 @@ class View(JenkinsBase):
         """
         True if view_name is the name of a defined view
         """
-        return job_name in self.keys()
+        return job_name in list(self.keys())
 
     def delete(self):
         """
@@ -52,24 +52,24 @@ class View(JenkinsBase):
         self.deleted = True
 
     def keys(self):
-        return self.get_job_dict().keys()
+        return list(self.get_job_dict().keys())
 
     def iteritems(self):
         try:
-            it = self.get_job_dict().iteritems()
+            it = iter(self.get_job_dict().items())
         except AttributeError:
             # Python3
-            it = self.get_job_dict().items()
+            it = list(self.get_job_dict().items())
 
         for name, url in it:
             api_url = self.python_api_url(url)
             yield name, Job(api_url, name, self.jenkins_obj)
 
     def values(self):
-        return [a[1] for a in self.iteritems()]
+        return [a[1] for a in self.items()]
 
     def items(self):
-        return [a for a in self.iteritems()]
+        return [a for a in self.items()]
 
     def _get_jobs(self):
         if 'jobs' in self._data:
@@ -80,14 +80,14 @@ class View(JenkinsBase):
         return dict(self._get_jobs())
 
     def __len__(self):
-        return len(self.get_job_dict().keys())
+        return len(list(self.get_job_dict().keys()))
 
     def get_job_url(self, str_job_name):
         if str_job_name in self:
             return self.get_job_dict()[str_job_name]
         else:
             # noinspection PyUnboundLocalVariable
-            views_jobs = ", ".join(self.get_job_dict().keys())
+            views_jobs = ", ".join(list(self.get_job_dict().keys()))
             raise NotFound("Job %s is not known, available jobs"
                            " in view are: %s" % (str_job_name, views_jobs))
 
@@ -145,7 +145,7 @@ class View(JenkinsBase):
         }
         data["name"] = self.name
         # Add existing jobs (if any)
-        for job_name in self.get_job_dict().keys():
+        for job_name in list(self.get_job_dict().keys()):
             data[job_name] = 'on'
 
         # Add new job
@@ -184,7 +184,7 @@ class View(JenkinsBase):
         """
         url = self.get_config_xml_url()
         try:
-            if isinstance(config, unicode):  # pylint: disable=undefined-variable
+            if isinstance(config, str):  # pylint: disable=undefined-variable
                 config = str(config)
         except NameError:
             # Python3 already a str
index bac9b70abb087ef986fcebd36b9319db6ee43296..5c5e9787c9689cf18a0b64a4aa11ed6e1121cd1e 100644 (file)
@@ -23,7 +23,7 @@ class Views(object):
         self.jenkins = jenkins
 
     def __len__(self):
-        return len(self.keys())
+        return len(list(self.keys()))
 
     def __delitem__(self, view_name):
         if view_name == 'All':
@@ -63,7 +63,7 @@ class Views(object):
         """
         True if view_name is the name of a defined view
         """
-        return view_name in self.keys()
+        return view_name in list(self.keys())
 
     def iterkeys(self):
         """
@@ -76,7 +76,7 @@ class Views(object):
         """
         Return a list of the names of all views
         """
-        return list(self.iterkeys())
+        return list(self.keys())
 
     def create(self, view_name, view_type=LIST_VIEW):
         """
index 8f7124528a7bf1d90469a0eb3e3e4dde29ccc327..acc2ab81e43acad9859ec49760809bd065042896 100644 (file)
@@ -30,11 +30,11 @@ class BaseSystemTest(unittest.TestCase):
 
     def _delete_all_jobs(self):
         self.jenkins.poll()
-        for name in self.jenkins.keys():
+        for name in list(self.jenkins.keys()):
             del self.jenkins[name]
 
     def _delete_all_views(self):
-        all_view_names = self.jenkins.views.keys()[1:]
+        all_view_names = list(self.jenkins.views.keys())[1:]
         for name in all_view_names:
             del self.jenkins.views[name]
 
index 1d25205382a806dca6192177909221c49af4c720..1fa7fc3f1f4c893ec2e7b7dd6f49b9f36771dfef 100644 (file)
@@ -96,7 +96,7 @@ class TestDownstreamUpstream(BaseSystemTest):
         """
         Can we keep track of the relationships between upstream & downstream jobs?
         """
-        for job_name, job_config in JOB_CONFIGS.items():
+        for job_name, job_config in list(JOB_CONFIGS.items()):
             self.jenkins.create_job(job_name, job_config)
 
         self.jenkins['A'].invoke()
index 6dcab055b5d28a95e36564c99c853720e44436f0..4e1ef7d1ef63d4bc65e7bfd2a27f06a97ac33ba3 100644 (file)
@@ -29,7 +29,7 @@ class TestInvocation(BaseSystemTest):
         self.assertIsInstance(qq, QueueItem)
         # Let Jenkins catchup
         qq.block_until_building()
-        self.assertEquals(qq.get_build_number(), 1)
+        self.assertEqual(qq.get_build_number(), 1)
 
     def test_get_block_until_build_running(self):
         job_name = 'Bcreate_%s' % random_string()
@@ -68,7 +68,7 @@ class TestInvocation(BaseSystemTest):
             ii.block_until_complete(delay=2)
 
         build_number = job.get_last_good_buildnumber()
-        self.assertEquals(build_number, 3)
+        self.assertEqual(build_number, 3)
 
         build = job.get_build(build_number)
         self.assertIsInstance(build, Build)
@@ -82,7 +82,7 @@ class TestInvocation(BaseSystemTest):
             qq = job.invoke()
             qq.block_until_complete(delay=1)
             build_number = qq.get_build_number()
-            self.assertEquals(build_number, invocation + 1)
+            self.assertEqual(build_number, invocation + 1)
 
     def test_give_params_on_non_parameterized_job(self):
         job_name = 'Ecreate_%s' % random_string()
index 9614836b5afe32cb38cdb6ac1e9c51815c633893..68246d130a0d4ee9324bb554642a850b10b2cefe 100644 (file)
@@ -35,16 +35,16 @@ class JobTests(BaseSystemTest):
         j.invoke(block=True)  # run this at least once
 
         j.disable()
-        self.assertEquals(j.is_enabled(), False, 'A disabled job is reporting incorrectly')
+        self.assertEqual(j.is_enabled(), False, 'A disabled job is reporting incorrectly')
         j.enable()
-        self.assertEquals(j.is_enabled(), True, 'An enabled job is reporting incorrectly')
+        self.assertEqual(j.is_enabled(), True, 'An enabled job is reporting incorrectly')
 
     def test_get_job_and_update_config(self):
         job_name = 'config_%s' % random_string()
         self.jenkins.create_job(job_name, EMPTY_JOB)
         self.assertJobIsPresent(job_name)
         config = self.jenkins[job_name].get_config()
-        self.assertEquals(config.strip(), EMPTY_JOB.strip())
+        self.assertEqual(config.strip(), EMPTY_JOB.strip())
         self.jenkins[job_name].update_config(EMPTY_JOB)
 
     def test_invoke_job(self):
@@ -93,11 +93,11 @@ class JobTests(BaseSystemTest):
         self.assertJobIsPresent(template_job_name)
         self.assertJobIsPresent(copied_job_name)
         self.assertIsInstance(j, Job)
-        self.assertEquals(j.name, copied_job_name)
+        self.assertEqual(j.name, copied_job_name)
 
     def test_get_master_data(self):
         master_data = self.jenkins.get_master_data()
-        self.assertEquals(master_data['totalExecutors'], 2)
+        self.assertEqual(master_data['totalExecutors'], 2)
         
     def test_get_missing_plugin(self):
         plugins = self.jenkins.get_plugins()
@@ -106,13 +106,13 @@ class JobTests(BaseSystemTest):
             
     def test_get_single_plugin(self):
         plugins = self.jenkins.get_plugins()
-        plugin_name, plugin = next(plugins.iteritems())
+        plugin_name, plugin = next(iter(plugins.items()))
         self.assertIsInstance(plugin_name, str)
         self.assertIsInstance(plugin, Plugin)
         
     def test_get_single_plugin_depth_2(self):
         plugins = self.jenkins.get_plugins(depth=2)
-        _, plugin = next(plugins.iteritems())
+        _, plugin = next(iter(plugins.items()))
 
 if __name__ == '__main__':
     unittest.main()
index ce1c4e53e72fe6d6f4079611e075369eac53d70f..c0ceb81169fe5c5607f5dc3d67871d78547c0452 100644 (file)
@@ -29,9 +29,9 @@ class TestMatrixJob(BaseSystemTest):
 
         set_of_groups = set()
         for run in build.get_matrix_runs():
-            self.assertEquals(run.get_number(), build.get_number())
-            self.assertEquals(run.get_upstream_build(), build)
-            match_result = re.search(u'\xbb (.*) #\\d+$', run.name)
+            self.assertEqual(run.get_number(), build.get_number())
+            self.assertEqual(run.get_upstream_build(), build)
+            match_result = re.search('\xbb (.*) #\\d+$', run.name)
             self.assertIsNotNone(match_result)
             set_of_groups.add(match_result.group(1))
             build.get_master_job_name()
index 4c021f2aceec9dd3fc7fe0d8d521102796ebe6e5..03e711f2014377453dac205f40f413485b480675 100644 (file)
@@ -22,7 +22,7 @@ class TestNodes(BaseSystemTest):
             self.assertTrue(self.jenkins.has_node(node_name))
     
             N = self.jenkins.get_node(node_name)
-            self.assertEquals(N.baseurl, self.jenkins.get_node_url(node_name))
+            self.assertEqual(N.baseurl, self.jenkins.get_node_url(node_name))
         
         finally:
             self.jenkins.delete_node(node_name)
index 7869c4ca528c242c6cbf690148de8a77c1d278e6..3a1832a56bfa6e2fe11a64d6b0387ea1276b1303 100644 (file)
@@ -8,7 +8,7 @@ try:
 except ImportError:
     import unittest
 try:
-    from StringIO import StringIO
+    from io import StringIO
 except ImportError:
     from io import StringIO
 from jenkinsapi_tests.systests.base import BaseSystemTest
index e53cf3821992ea1c2aa381ad7848cdc1f3025b0b..b1e77ee763a97165b631889f0c97627862655837 100644 (file)
@@ -42,12 +42,12 @@ class TestQueue(BaseSystemTest):
         reprString = repr(queue)
         self.assertIn(queue.baseurl, reprString)
 
-        for _, item in queue.iteritems():
+        for _, item in queue.items():
             queue.delete_item(item)
 
         queue.poll()
 
-        self.assertEquals(len(queue), 0)
+        self.assertEqual(len(queue), 0)
 
     def test_start_and_stop_long_running_job(self):
         job_name = random_string()
index 76e948c500921d7199fa55836ff1d94ae50de8b5..184be4de352614a576745a0101f88b0ad995d7d2 100644 (file)
@@ -29,7 +29,7 @@ class TestViews(BaseSystemTest):
 
         # Can we use the API convenience methods
         v2 = get_view_from_url(v.baseurl)
-        self.assertEquals(v, v2)
+        self.assertEqual(v, v2)
 
     def test_create_and_delete_views(self):
         self._create_job()
@@ -67,10 +67,10 @@ class TestViews(BaseSystemTest):
         self.assertIn(view_name, self.jenkins.views)
         config = self.jenkins.views[view_name].get_config().strip()
         new_view_config = VIEW_WITH_FILTER_AND_REGEX % view_name
-        self.assertNotEquals(config, new_view_config)
+        self.assertNotEqual(config, new_view_config)
         self.jenkins.views[view_name].update_config(new_view_config)
         config = self.jenkins.views[view_name].get_config().strip()
-        self.assertEquals(config, new_view_config)
+        self.assertEqual(config, new_view_config)
 
     def test_make_nested_views(self):
         job = self._create_job()
@@ -97,7 +97,7 @@ class TestViews(BaseSystemTest):
 
         # Can we use the API convenience methods
         v = get_view_from_url(sv2.baseurl)
-        self.assertEquals(v, sv2)
+        self.assertEqual(v, sv2)
 
 if __name__ == '__main__':
     logging.basicConfig()
index 18f13fa4d4bba2d5afa7b238187857b8d9c0a954..c10069329dbba3afb368c46a1625caf2c9bc5694 100644 (file)
@@ -1,4 +1,4 @@
-from __future__ import print_function
+
 
 import random
 import string
index 549bd2e7eb11cf15141506834efa081cf7d6d743..37bdb79388d50909c367937b2952463931c023db 100644 (file)
@@ -1,5 +1,5 @@
 import pytz
-import mock
+from unittest import mock
 # To run unittests on python 2.6 please use unittest2 library
 try:
     import unittest2 as unittest
@@ -66,17 +66,17 @@ class test_build(unittest.TestCase):
     def testName(self):
         with self.assertRaises(AttributeError):
             self.b.id()
-        self.assertEquals(self.b.name, 'foo #1')
+        self.assertEqual(self.b.name, 'foo #1')
 
     def test_duration(self):
         expected = datetime.timedelta(milliseconds=5782)
-        self.assertEquals(self.b.get_duration(), expected)
-        self.assertEquals(self.b.get_duration().seconds, 5)
-        self.assertEquals(self.b.get_duration().microseconds, 782000)
-        self.assertEquals(str(self.b.get_duration()), '0:00:05.782000')
+        self.assertEqual(self.b.get_duration(), expected)
+        self.assertEqual(self.b.get_duration().seconds, 5)
+        self.assertEqual(self.b.get_duration().microseconds, 782000)
+        self.assertEqual(str(self.b.get_duration()), '0:00:05.782000')
 
     def test_get_causes(self):
-        self.assertEquals(self.b.get_causes(),
+        self.assertEqual(self.b.get_causes(),
                           [{'shortDescription': 'Started by user anonymous',
                             'userId': None,
                             'userName': 'anonymous'}])
index e2f09d5b751bf659d4d4279217fdcaafe37b1716..ae5c74eed05cdcb3c54e11240af583c183be8c68 100644 (file)
@@ -1,4 +1,4 @@
-import mock
+from unittest import mock
 # To run unittests on python 2.6 please use unittest2 library
 try:
     import unittest2 as unittest
@@ -103,11 +103,11 @@ class test_build(unittest.TestCase):
         Can we extract git build revision data from a build object?
         """
         try:
-            self.assertIsInstance(self.b.get_revision(), basestring)
+            self.assertIsInstance(self.b.get_revision(), str)
         except NameError:
             # Python3
             self.assertIsInstance(self.b.get_revision(), str)
-        self.assertEquals(self.b.get_revision(),
+        self.assertEqual(self.b.get_revision(),
                           '7def9ed6e92580f37d00e4980c36c4d36e68f702')
 
     def test_git_revision_branch(self):
@@ -115,11 +115,11 @@ class test_build(unittest.TestCase):
         Can we extract git build branch from a build object?
         """
         self.assertIsInstance(self.b.get_revision_branch(), list)
-        self.assertEquals(len(self.b.get_revision_branch()), 1)
+        self.assertEqual(len(self.b.get_revision_branch()), 1)
         self.assertIsInstance(self.b.get_revision_branch()[0], dict)
-        self.assertEquals(self.b.get_revision_branch()[0]['SHA1'],
+        self.assertEqual(self.b.get_revision_branch()[0]['SHA1'],
                           '7def9ed6e92580f37d00e4980c36c4d36e68f702')
-        self.assertEquals(self.b.get_revision_branch()[0]['name'],
+        self.assertEqual(self.b.get_revision_branch()[0]['name'],
                           'origin/unstable')
 
 if __name__ == '__main__':
index 03e0b7ccfe339e4baa61b7ffbdf94c255a5cb146..0259248938c92edfa4cc08e742bc3dbaf0119f4b 100644 (file)
@@ -1,4 +1,4 @@
-import mock
+from unittest import mock
 import types
 # To run unittests on python 2.6 please use unittest2 library
 try:
@@ -269,7 +269,7 @@ class TestExecutors(unittest.TestCase):
         assert repr(self.J)
 
     def testCheckURL(self):
-        self.assertEquals(self.J.baseurl, 'http://localhost:8080')
+        self.assertEqual(self.J.baseurl, 'http://localhost:8080')
 
     @mock.patch.object(Executors, '_poll')
     @mock.patch.object(Executor, '_poll')
@@ -282,7 +282,7 @@ class TestExecutors(unittest.TestCase):
         self.assertIsInstance(repr(exec_info), str)
 
         for e in exec_info:
-            self.assertEquals(e.get_progress(), 48, 'Should return 48 %')
+            self.assertEqual(e.get_progress(), 48, 'Should return 48 %')
 
     @mock.patch.object(Executors, '_poll')
     @mock.patch.object(Executor, '_poll')
@@ -293,9 +293,9 @@ class TestExecutors(unittest.TestCase):
 
         self.assertIsInstance(exec_info, object)
         for e in exec_info:
-            self.assertEquals(e.get_progress(), -1, 'Should return 48 %')
-            self.assertEquals(e.is_idle(), True, 'Should return True')
-            self.assertEquals(
+            self.assertEqual(e.get_progress(), -1, 'Should return 48 %')
+            self.assertEqual(e.is_idle(), True, 'Should return True')
+            self.assertEqual(
                 repr(e),
                 '<jenkinsapi.executor.Executor host3.host.com 0>'
             )
@@ -306,7 +306,7 @@ class TestExecutors(unittest.TestCase):
         baseurl = 'http://localhost:8080/computer/host0.host.com/executors/0'
         nodename = 'host0.host.com'
         single_executer = Executor(baseurl, nodename, self.J, '0')
-        self.assertEquals(single_executer.likely_stuck(), False)
+        self.assertEqual(single_executer.likely_stuck(), False)
 
     @mock.patch.object(Executor, '_poll')
     def test_get_current_executable(self, _poll_executor):
@@ -314,11 +314,11 @@ class TestExecutors(unittest.TestCase):
         baseurl = 'http://localhost:8080/computer/host0.host.com/executors/0'
         nodename = 'host0.host.com'
         single_executer = Executor(baseurl, nodename, self.J, '0')
-        self.assertEquals(
+        self.assertEqual(
             single_executer.get_current_executable()['number'],
             4168
         )
-        self.assertEquals(
+        self.assertEqual(
             single_executer.get_current_executable()['url'],
             'http://localhost:8080/job/testjob/4168/'
         )
index 90e648fe5b2a9700e5c74906edb6337f865732a9..a68d5b2c0fb26c66df1637885e9c9e8ee0e4adda 100644 (file)
@@ -1,4 +1,4 @@
-import mock
+from unittest import mock
 # To run unittests on python 2.6 please use unittest2 library
 try:
     import unittest2 as unittest
@@ -26,7 +26,7 @@ class TestFingerprint(unittest.TestCase):
         J = Jenkins(self.baseurl, username='foouser', password='foopassword')
         self.fp_instance = Fingerprint(self.baseurl, self.dummy_md5, J)
         self.assertTrue(isinstance(self.fp_instance, Fingerprint))
-        self.assertEquals(str(self.fp_instance), self.dummy_md5)
+        self.assertEqual(str(self.fp_instance), self.dummy_md5)
         self.assertTrue(self.fp_instance.valid())
 
     @mock.patch.object(Jenkins, '_poll')
index 1f2a74bc1c06e2fc13883a60e0a233502063aaf2..ae4c3c6fcb0fd2aadb4f2ac3fb9e8d3ddc81b118 100644 (file)
@@ -1,4 +1,4 @@
-import mock
+from unittest import mock
 # To run unittests on python 2.6 please use unittest2 library
 try:
     import unittest2 as unittest
@@ -25,12 +25,12 @@ class TestJenkins(unittest.TestCase):
     def test_clone(self, _poll):
         _poll.return_value = self.DATA
         JJ = self.J._clone()
-        self.assertNotEquals(id(JJ), id(self.J))
-        self.assertEquals(JJ, self.J)
+        self.assertNotEqual(id(JJ), id(self.J))
+        self.assertEqual(JJ, self.J)
 
     def test_stored_passwords(self):
-        self.assertEquals(self.J.requester.password, 'foopassword')
-        self.assertEquals(self.J.requester.username, 'foouser')
+        self.assertEqual(self.J.requester.password, 'foopassword')
+        self.assertEqual(self.J.requester.username, 'foouser')
 
     @mock.patch.object(Jenkins, '_poll')
     def test_reload(self, _poll):
@@ -56,10 +56,10 @@ class TestJenkins(unittest.TestCase):
         J = Jenkins('http://localhost:8080/',
                     username='foouser', password='foopassword')
         for idx, (job_name, job) in enumerate(J.get_jobs()):
-            self.assertEquals(job_name, _poll.return_value['jobs'][idx]['name'])
+            self.assertEqual(job_name, _poll.return_value['jobs'][idx]['name'])
             self.assertTrue(isinstance(job, Job))
-            self.assertEquals(job.name, _poll.return_value['jobs'][idx]['name'])
-            self.assertEquals(job.baseurl, _poll.return_value['jobs'][idx]['url'])
+            self.assertEqual(job.name, _poll.return_value['jobs'][idx]['name'])
+            self.assertEqual(job.baseurl, _poll.return_value['jobs'][idx]['url'])
 
     @mock.patch.object(JenkinsBase, '_poll')
     @mock.patch.object(Jenkins, '_poll')
@@ -76,13 +76,13 @@ class TestJenkins(unittest.TestCase):
         J = Jenkins('http://localhost:8080/',
                     username='foouser', password='foopassword', lazy=True)
 
-        self.assertEquals(J._data, None)
+        self.assertEqual(J._data, None)
 
         for idx, (job_name, job) in enumerate(J.get_jobs()):
-            self.assertEquals(job_name, _poll.return_value['jobs'][idx]['name'])
+            self.assertEqual(job_name, _poll.return_value['jobs'][idx]['name'])
             self.assertTrue(isinstance(job, Job))
-            self.assertEquals(job.name, _poll.return_value['jobs'][idx]['name'])
-            self.assertEquals(job.baseurl, _poll.return_value['jobs'][idx]['url'])
+            self.assertEqual(job.name, _poll.return_value['jobs'][idx]['name'])
+            self.assertEqual(job.baseurl, _poll.return_value['jobs'][idx]['url'])
 
     @mock.patch.object(JenkinsBase, '_poll')
     @mock.patch.object(Jenkins, '_poll')
@@ -99,8 +99,8 @@ class TestJenkins(unittest.TestCase):
         J = Jenkins('http://localhost:8080/',
                     username='foouser', password='foopassword')
         for idx, (url, job_name) in enumerate(J.get_jobs_info()):
-            self.assertEquals(job_name, _poll.return_value['jobs'][idx]['name'])
-            self.assertEquals(url, _poll.return_value['jobs'][idx]['url'])
+            self.assertEqual(job_name, _poll.return_value['jobs'][idx]['name'])
+            self.assertEqual(url, _poll.return_value['jobs'][idx]['url'])
 
     @mock.patch.object(JenkinsBase, '_poll')
     @mock.patch.object(Jenkins, '_poll')
@@ -117,7 +117,7 @@ class TestJenkins(unittest.TestCase):
         J = Jenkins('http://localhost:8080/',
                     username='foouser', password='foopassword')
         for idx, job_name in enumerate(J.get_jobs_list()):
-            self.assertEquals(job_name, _poll.return_value['jobs'][idx]['name'])
+            self.assertEqual(job_name, _poll.return_value['jobs'][idx]['name'])
 
     @mock.patch.object(JenkinsBase, '_poll')
     @mock.patch.object(Jenkins, '_poll')
@@ -135,8 +135,8 @@ class TestJenkins(unittest.TestCase):
                     username='foouser', password='foopassword')
         job = J.get_job('job_one')
         self.assertTrue(isinstance(job, Job))
-        self.assertEquals(job.name, _poll.return_value['jobs'][0]['name'])
-        self.assertEquals(job.baseurl, _poll.return_value['jobs'][0]['url'])
+        self.assertEqual(job.name, _poll.return_value['jobs'][0]['name'])
+        self.assertEqual(job.baseurl, _poll.return_value['jobs'][0]['url'])
 
     @mock.patch.object(JenkinsBase, '_poll')
     @mock.patch.object(Jenkins, '_poll')
@@ -282,7 +282,7 @@ class TestJenkins(unittest.TestCase):
         with self.assertRaises(JenkinsAPIException) as ar:
             J.create_job('job_new', None)
 
-        self.assertEquals(str(ar.exception), 'Cannot create job job_new')
+        self.assertEqual(str(ar.exception), 'Cannot create job job_new')
 
     @mock.patch.object(JenkinsBase, '_poll')
     @mock.patch.object(Jenkins, '_poll')
@@ -305,10 +305,10 @@ class TestJenkins(unittest.TestCase):
                     requester=mock_requester)
 
         new_jenkins = J.get_jenkins_obj_from_url('http://localhost:8080/')
-        self.assertEquals(new_jenkins, J)
+        self.assertEqual(new_jenkins, J)
 
         new_jenkins = J.get_jenkins_obj_from_url('http://localhost:8080/foo')
-        self.assertNotEquals(new_jenkins, J)
+        self.assertNotEqual(new_jenkins, J)
 
     @mock.patch.object(JenkinsBase, '_poll')
     @mock.patch.object(Jenkins, '_poll')
@@ -331,7 +331,7 @@ class TestJenkins(unittest.TestCase):
                     requester=mock_requester)
 
         new_jenkins = J.get_jenkins_obj()
-        self.assertEquals(new_jenkins, J)
+        self.assertEqual(new_jenkins, J)
 
     @mock.patch.object(JenkinsBase, '_poll')
     @mock.patch.object(Jenkins, '_poll')
@@ -345,7 +345,7 @@ class TestJenkins(unittest.TestCase):
         J = Jenkins('http://localhost:8080/',
                     username='foouser', password='foopassword',
                     requester=mock_requester)
-        self.assertEquals('1.542', J.version)
+        self.assertEqual('1.542', J.version)
 
     @mock.patch.object(JenkinsBase, '_poll')
     @mock.patch.object(Jenkins, '_poll')
@@ -359,7 +359,7 @@ class TestJenkins(unittest.TestCase):
         J = Jenkins(base_url,
                     username='foouser', password='foopassword',
                     requester=mock_requester)
-        self.assertEquals('0.0', J.version)
+        self.assertEqual('0.0', J.version)
 
     @mock.patch.object(JenkinsBase, 'get_data')
     def test_get_master_data(self, _base_poll):
@@ -371,8 +371,8 @@ class TestJenkins(unittest.TestCase):
         j = Jenkins(base_url,
                     username='foouser', password='foopassword')
         data = j.get_master_data()
-        self.assertEquals(data['busyExecutors'], 59)
-        self.assertEquals(data['totalExecutors'], 75)
+        self.assertEqual(data['busyExecutors'], 59)
+        self.assertEqual(data['totalExecutors'], 75)
 
 
 class TestJenkinsURLs(unittest.TestCase):
@@ -382,14 +382,14 @@ class TestJenkinsURLs(unittest.TestCase):
         _poll.return_value = {}
         J = Jenkins('http://localhost:8080',
                     username='foouser', password='foopassword')
-        self.assertEquals(J.get_create_url(), 'http://localhost:8080/createItem')
+        self.assertEqual(J.get_create_url(), 'http://localhost:8080/createItem')
 
     @mock.patch.object(Jenkins, '_poll')
     def testWithSlash(self, _poll):
         _poll.return_value = {}
         J = Jenkins('http://localhost:8080/',
                     username='foouser', password='foopassword')
-        self.assertEquals(J.get_create_url(), 'http://localhost:8080/createItem')
+        self.assertEqual(J.get_create_url(), 'http://localhost:8080/createItem')
 
     @mock.patch.object(Jenkins, '_poll')
     @mock.patch.object(Plugins, '_poll')
index 8096316ddfb2bed9e5318c1fe4b2a35b8e4776b3..1c9087c6e68918e754c2c1c3baff0761a179dfa2 100644 (file)
@@ -1,4 +1,4 @@
-import mock
+from unittest import mock
 import json
 # To run unittests on python 2.6 please use unittest2 library
 try:
@@ -111,37 +111,37 @@ class TestJob(unittest.TestCase):
 
     def testRepr(self):
         # Can we produce a repr string for this object
-        self.assertEquals(repr(self.j), '<jenkinsapi.job.Job foo>')
+        self.assertEqual(repr(self.j), '<jenkinsapi.job.Job foo>')
 
     def testName(self):
         with self.assertRaises(AttributeError):
             self.j.id()
-        self.assertEquals(self.j.name, 'foo')
+        self.assertEqual(self.j.name, 'foo')
 
     def testNextBuildNumber(self):
-        self.assertEquals(self.j.get_next_build_number(), 4)
+        self.assertEqual(self.j.get_next_build_number(), 4)
 
     def test_special_urls(self):
-        self.assertEquals(self.j.baseurl, 'http://halob:8080/job/foo')
+        self.assertEqual(self.j.baseurl, 'http://halob:8080/job/foo')
 
-        self.assertEquals(
+        self.assertEqual(
             self.j.get_delete_url(), 'http://halob:8080/job/foo/doDelete')
 
-        self.assertEquals(
+        self.assertEqual(
             self.j.get_rename_url(), 'http://halob:8080/job/foo/doRename')
 
     def test_get_description(self):
-        self.assertEquals(self.j.get_description(), 'test job')
+        self.assertEqual(self.j.get_description(), 'test job')
 
     def test_get_build_triggerurl(self):
-        self.assertEquals(self.j.get_build_triggerurl(None),
+        self.assertEqual(self.j.get_build_triggerurl(None),
                           'http://halob:8080/job/foo/buildWithParameters')
 
     def test_wrong__mk_json_from_build_parameters(self):
         with self.assertRaises(AssertionError) as ar:
             self.j._mk_json_from_build_parameters(build_params='bad parameter')
 
-        self.assertEquals(
+        self.assertEqual(
             str(ar.exception), 'Build parameters must be a dict')
 
     @mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
@@ -167,18 +167,18 @@ class TestJob(unittest.TestCase):
     @mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
     def test_get_last_buildnumber(self):
         ret = self.j.get_last_buildnumber()
-        self.assertEquals(ret, 4)
+        self.assertEqual(ret, 4)
 
     @mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
     def test_get_last_completed_buildnumber(self):
         ret = self.j.get_last_completed_buildnumber()
-        self.assertEquals(ret, 3)
+        self.assertEqual(ret, 3)
 
     @mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
     def test_get_build_dict(self):
         ret = self.j.get_build_dict()
         self.assertTrue(isinstance(ret, dict))
-        self.assertEquals(len(ret), 4)
+        self.assertEqual(len(ret), 4)
 
     @mock.patch.object(JenkinsBase, 'get_data', fake_get_data_tree_empty)
     def test_nobuilds_get_build_dict(self):
@@ -192,7 +192,7 @@ class TestJob(unittest.TestCase):
         # So we convert result to a list
         ret = list(self.j.get_build_ids())
         self.assertTrue(isinstance(ret, list))
-        self.assertEquals(len(ret), 4)
+        self.assertEqual(len(ret), 4)
 
     @mock.patch.object(Job, '_poll')
     def test_nobuilds_get_revision_dict(self, _poll):
@@ -226,9 +226,9 @@ class TestJob(unittest.TestCase):
         mock_data = TestJob.URL_DATA[url].copy()
         mock_data['firstBuild'] = {'number': 1}
         del mock_data['builds'][-1]
-        self.assertEquals(len(mock_data['builds']), 2)
+        self.assertEqual(len(mock_data['builds']), 2)
         new_data = j._add_missing_builds(mock_data)
-        self.assertEquals(len(new_data['builds']), 3)
+        self.assertEqual(len(new_data['builds']), 3)
 
     @mock.patch.object(JenkinsBase, 'get_data')
     def test__add_missing_builds_no_first_build(self, get_data):
@@ -240,7 +240,7 @@ class TestJob(unittest.TestCase):
         mock_data = TestJob.URL_DATA[url].copy()
         mock_data['firstBuild'] = None
         j._add_missing_builds(mock_data)
-        self.assertEquals(initial_call_count, get_data.call_count)
+        self.assertEqual(initial_call_count, get_data.call_count)
 
     @mock.patch.object(JenkinsBase, 'get_data')
     def test__add_missing_builds_no_builds(self, get_data):
@@ -252,7 +252,7 @@ class TestJob(unittest.TestCase):
         mock_data = TestJob.URL_DATA[url].copy()
         mock_data['builds'] = None
         j._add_missing_builds(mock_data)
-        self.assertEquals(initial_call_count, get_data.call_count)
+        self.assertEqual(initial_call_count, get_data.call_count)
 
     @mock.patch.object(JenkinsBase, 'get_data')
     def test_get_params(self, get_data):
@@ -260,7 +260,7 @@ class TestJob(unittest.TestCase):
         get_data.return_value = TestJob.URL_DATA[url].copy()
         j = Job('http://halob:8080/job/foo/', 'foo', self.J)
         params = list(j.get_params())
-        self.assertEquals(len(params), 2)
+        self.assertEqual(len(params), 2)
 
     @mock.patch.object(JenkinsBase, 'get_data')
     def test_get_params_list(self, get_data):
@@ -272,8 +272,8 @@ class TestJob(unittest.TestCase):
         params = j.get_params_list()
 
         self.assertIsInstance(params, list)
-        self.assertEquals(len(params), 2)
-        self.assertEquals(params, ['param1', 'param2'])
+        self.assertEqual(len(params), 2)
+        self.assertEqual(params, ['param1', 'param2'])
 
     @mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
     # @mock.patch.object(JenkinsBase, 'get_data', fakeGetLastBuild)
@@ -282,7 +282,7 @@ class TestJob(unittest.TestCase):
         with mock.patch('jenkinsapi.job.Build') as build_mock:
             instance = build_mock.return_value
             build = self.j.get_build(buildnumber)
-            self.assertEquals(build, instance)
+            self.assertEqual(build, instance)
             build_mock.assert_called_with('http://halob:8080/job/foo/1/',
                                           buildnumber, job=self.j)
 
@@ -292,7 +292,7 @@ class TestJob(unittest.TestCase):
         with mock.patch('jenkinsapi.job.Build') as build_mock:
             instance = build_mock.return_value
             build = self.j.get_build_metadata(buildnumber)
-            self.assertEquals(build, instance)
+            self.assertEqual(build, instance)
             build_mock.assert_called_with('http://halob:8080/job/foo/1/',
                                           buildnumber, job=self.j, depth=0)
 
@@ -327,7 +327,7 @@ class TestJob(unittest.TestCase):
         result = self.j._mk_json_from_build_parameters(build_params=params)
         self.assertTrue(isinstance(result, dict))
 
-        self.assertEquals(
+        self.assertEqual(
             result,
             {"parameter": [{"name": "param1", "value": "value1"}, {
                 "name": "param2", "value": "value2"}]}
@@ -337,7 +337,7 @@ class TestJob(unittest.TestCase):
         with self.assertRaises(AssertionError) as ar:
             self.j.mk_json_from_build_parameters(build_params='bad parameter')
 
-        self.assertEquals(
+        self.assertEqual(
             str(ar.exception), 'Build parameters must be a dict')
 
 if __name__ == '__main__':
index b9a7e8bdd1a9d022f2e0042bc5e57dc6aabda434..eab0c6261809537c169b533bd33eda5596d0dc92 100644 (file)
@@ -1,4 +1,4 @@
-import mock
+from unittest import mock
 # To run unittests on python 2.6 please use unittest2 library
 try:
     import unittest2 as unittest
@@ -55,7 +55,7 @@ class TestJobFolders(unittest.TestCase):
             },
         ]
 
-        self.assertEquals(
+        self.assertEqual(
             self.jb.resolve_job_folders(jobs),
             [
                 {
@@ -81,7 +81,7 @@ class TestJobFolders(unittest.TestCase):
             },
         ]
 
-        self.assertEquals(self.jb.resolve_job_folders(jobs), [])
+        self.assertEqual(self.jb.resolve_job_folders(jobs), [])
         get_data_mock.assert_called_once_with('http://localhost:8080/job/Folder1/api/python')
 
     @mock.patch('jenkinsapi.jenkins.JenkinsBase.get_data')
@@ -106,7 +106,7 @@ class TestJobFolders(unittest.TestCase):
             },
         ]
 
-        self.assertEquals(
+        self.assertEqual(
             self.jb.resolve_job_folders(jobs),
             [
                 {
@@ -160,7 +160,7 @@ class TestJobFolders(unittest.TestCase):
             },
         ]
 
-        self.assertEquals(
+        self.assertEqual(
             self.jb.resolve_job_folders(jobs),
             [
                 {
@@ -176,7 +176,7 @@ class TestJobFolders(unittest.TestCase):
             ]
         )
 
-        self.assertEquals(
+        self.assertEqual(
             get_data_mock.call_args_list,
             [
                 mock.call('http://localhost:8080/job/Folder1/api/python'),
@@ -226,7 +226,7 @@ class TestJobFolders(unittest.TestCase):
             },
         ]
 
-        self.assertEquals(
+        self.assertEqual(
             self.jb.resolve_job_folders(jobs),
             [
                 {
@@ -247,7 +247,7 @@ class TestJobFolders(unittest.TestCase):
             ]
         )
 
-        self.assertEquals(
+        self.assertEqual(
             get_data_mock.call_args_list,
             [
                 mock.call('http://localhost:8080/job/Folder1/api/python'),
index 3fee88b1ac5d980dfde06f315ff0106a95f0e92d..8ac66e19dda9a3ef39cdda40ac9221f58b1a6d9d 100644 (file)
@@ -1,4 +1,4 @@
-import mock
+from unittest import mock
 # To run unittests on python 2.6 please use unittest2 library
 try:
     import unittest2 as unittest
@@ -177,7 +177,7 @@ class TestJobGetAllBuilds(unittest.TestCase):
         # remaining jobs will be fetched automatically
         ret = self.j.get_build_dict()
         self.assertTrue(isinstance(ret, dict))
-        self.assertEquals(len(ret), 4)
+        self.assertEqual(len(ret), 4)
 
     @mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
     def test_incomplete_builds_list_will_call_jenkins_twice(self):
@@ -186,14 +186,14 @@ class TestJobGetAllBuilds(unittest.TestCase):
         # the Jenkins API
         TestJobGetAllBuilds.__get_data_call_count = 0
         self.j = Job('http://halob:8080/job/foo/', 'foo', self.J)
-        self.assertEquals(TestJobGetAllBuilds.__get_data_call_count, 2)
+        self.assertEqual(TestJobGetAllBuilds.__get_data_call_count, 2)
 
     @mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
     def test_complete_builds_list_will_call_jenkins_once(self):
         # The job data contains all builds, so we will not gather remaining builds
         TestJobGetAllBuilds.__get_data_call_count = 0
         self.j = Job('http://halob:8080/job/fullfoo/', 'fullfoo', self.J)
-        self.assertEquals(TestJobGetAllBuilds.__get_data_call_count, 1)
+        self.assertEqual(TestJobGetAllBuilds.__get_data_call_count, 1)
 
     @mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
     def test_nobuilds_get_build_dict(self):
@@ -201,7 +201,7 @@ class TestJobGetAllBuilds(unittest.TestCase):
 
         ret = j.get_build_dict()
         self.assertTrue(isinstance(ret, dict))
-        self.assertEquals(len(ret), 0)
+        self.assertEqual(len(ret), 0)
 
     @mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
     def test_get_build_ids(self):
@@ -209,7 +209,7 @@ class TestJobGetAllBuilds(unittest.TestCase):
         # remaining jobs will be fetched automatically
         ret = list(self.j.get_build_ids())
         self.assertTrue(isinstance(ret, list))
-        self.assertEquals(len(ret), 4)
+        self.assertEqual(len(ret), 4)
 
 
 if __name__ == '__main__':
index ddc116934d4d9db1fbb861455bdc2cfc72af9dd0..6dfea9de2b20907999d23375f16a6256c8604083 100644 (file)
@@ -1,4 +1,4 @@
-import mock
+from unittest import mock
 # To run unittests on python 2.6 please use unittest2 library
 try:
     import unittest2 as unittest
index fa63e449ee85a5885069d3b07663a3ead3467e99..87898f30de37957ca42199a9c89b4f0e3b576008 100644 (file)
@@ -1,4 +1,4 @@
-import mock
+from unittest import mock
 # To run unittests on python 2.6 please use unittest2 library
 try:
     import unittest2 as unittest
@@ -95,13 +95,13 @@ class TestHgJob(unittest.TestCase):
     @mock.patch.object(Job,'get_config',configtree_with_branch)
     def test_hg_attributes(self):
         expected_url = ['http://cm5/hg/sandbox/v01.0/int']
-        self.assertEquals(self.j.get_scm_type(),'hg')
-        self.assertEquals(self.j.get_scm_url(),expected_url)
-        self.assertEquals(self.j.get_scm_branch(),['testme'])
+        self.assertEqual(self.j.get_scm_type(),'hg')
+        self.assertEqual(self.j.get_scm_url(),expected_url)
+        self.assertEqual(self.j.get_scm_branch(),['testme'])
 
     @mock.patch.object(Job,'get_config',configtree_with_default_branch)
     def test_hg_attributes_default_branch(self):
-        self.assertEquals(self.j.get_scm_branch(),['default'])
+        self.assertEqual(self.j.get_scm_branch(),['default'])
 
 if __name__ == '__main__':
     unittest.main()
index 211c3c8a51e169bc7a46af504f06095ce0481b69..c62d0992d63122c94e680714f28dfe0943569150 100644 (file)
@@ -1,4 +1,4 @@
-import mock
+from unittest import mock
 # To run unittests on python 2.6 please use unittest2 library
 try:
     import unittest2 as unittest
@@ -50,12 +50,12 @@ class TestNode(unittest.TestCase):
     def testName(self):
         with self.assertRaises(AttributeError):
             self.n.id()
-        self.assertEquals(self.n.name, 'bobnit')
+        self.assertEqual(self.n.name, 'bobnit')
 
     @mock.patch.object(Node, '_poll')
     def test_online(self, _poll):
         _poll.return_value = self.DATA
-        return self.assertEquals(self.n.is_online(), True)
+        return self.assertEqual(self.n.is_online(), True)
 
 if __name__ == '__main__':
     unittest.main()
index 6ae8467b330e59a6837ca682263d56172d04eb0f..c2847008c006ab0d70bb8badc306d5944ab402e0 100644 (file)
@@ -212,7 +212,7 @@ class TestNode(unittest.TestCase):
         repr(self.ns)
 
     def testCheckURL(self):
-        self.assertEquals(self.ns.baseurl, 'http://localhost:8080/computer')
+        self.assertEqual(self.ns.baseurl, 'http://localhost:8080/computer')
 
     @mock.patch.object(Node, '_poll')
     def testGetMasterNode(self, _poll_node):
index 33f4a997a9e97228a469437aceed365d17b35da7..05ad9301b44a031b0accdcedbafce14b08ee6dd4 100644 (file)
@@ -1,4 +1,4 @@
-import mock
+from unittest import mock
 # To run unittests on python 2.6 please use unittest2 library
 try:
     import unittest2 as unittest
@@ -66,21 +66,21 @@ class TestPlugins(unittest.TestCase):
         _poll_plugins.return_value = {}
 
         plugins = self.J.get_plugins()
-        self.assertEquals(str(plugins), "[]")
+        self.assertEqual(str(plugins), "[]")
 
     @mock.patch.object(Plugins, '_poll')
     def test_plugins_str(self, _poll_plugins):
         _poll_plugins.return_value = self.DATA
 
         plugins = self.J.get_plugins()
-        self.assertEquals(str(plugins), "['maven-plugin', 'subversion']")
+        self.assertEqual(str(plugins), "['maven-plugin', 'subversion']")
 
     @mock.patch.object(Plugins, '_poll')
     def test_plugins_len(self, _poll_plugins):
         _poll_plugins.return_value = self.DATA
 
         plugins = self.J.get_plugins()
-        self.assertEquals(len(plugins), 2)
+        self.assertEqual(len(plugins), 2)
 
     @mock.patch.object(Plugins, '_poll')
     def test_plugins_contains(self, _poll_plugins):
@@ -113,14 +113,14 @@ class TestPlugins(unittest.TestCase):
             }
         )
 
-        plugins = self.J.get_plugins().values()
+        plugins = list(self.J.get_plugins().values())
         self.assertIn(p, plugins)
 
     @mock.patch.object(Plugins, '_poll')
     def test_plugins_keys(self, _poll_plugins):
         _poll_plugins.return_value = self.DATA
 
-        plugins = self.J.get_plugins().keys()
+        plugins = list(self.J.get_plugins().keys())
         self.assertIn('subversion', plugins)
         self.assertIn('maven-plugin', plugins)
 
@@ -130,7 +130,7 @@ class TestPlugins(unittest.TestCase):
 
         # list() is required here for python 3.x compatibility
         plugins = list(self.J.get_plugins().keys())
-        self.assertEquals([], plugins)
+        self.assertEqual([], plugins)
 
     @mock.patch.object(Plugins, '_poll')
     def test_plugin_get_by_name(self, _poll_plugins):
@@ -156,16 +156,16 @@ class TestPlugins(unittest.TestCase):
         )
 
         plugin = self.J.get_plugins()['subversion']
-        self.assertEquals(p, plugin)
+        self.assertEqual(p, plugin)
 
     @mock.patch.object(Plugins, '_poll')
     def test_get_plugin_details(self, _poll_plugins):
         _poll_plugins.return_value = self.DATA
         plugin = self.J.get_plugins()['subversion']
-        self.assertEquals('1.45', plugin.version)
-        self.assertEquals('subversion', plugin.shortName)
-        self.assertEquals('Jenkins Subversion Plug-in', plugin.longName)
-        self.assertEquals('http://wiki.jenkins-ci.org/display/JENKINS/Subversion+Plugin',
+        self.assertEqual('1.45', plugin.version)
+        self.assertEqual('subversion', plugin.shortName)
+        self.assertEqual('Jenkins Subversion Plug-in', plugin.longName)
+        self.assertEqual('http://wiki.jenkins-ci.org/display/JENKINS/Subversion+Plugin',
                            plugin.url)
         
     def test_plugin_repr(self):
@@ -174,7 +174,7 @@ class TestPlugins(unittest.TestCase):
                 'shortName': 'subversion',
             }
         )
-        self.assertEquals(repr(p), '<jenkinsapi.plugin.Plugin subversion>')
+        self.assertEqual(repr(p), '<jenkinsapi.plugin.Plugin subversion>')
 
 if __name__ == '__main__':
     unittest.main()
index 967ab60d73179faf263a9ff0421aa16ef719f913..12467976b367a7c8222d933c19896a7566831591 100644 (file)
@@ -1,4 +1,4 @@
-import mock
+from unittest import mock
 # To run unittests on python 2.6 please use unittest2 library
 try:
     import unittest2 as unittest
@@ -145,10 +145,10 @@ class TestQueue(unittest.TestCase):
         self.assertTrue(repr(self.q))
 
     def test_length(self):
-        self.assertEquals(len(self.q), 3)
+        self.assertEqual(len(self.q), 3)
 
     def test_list_items(self):
-        self.assertEquals(set(self.q.keys()), set([40, 41, 42]))
+        self.assertEqual(set(self.q.keys()), set([40, 41, 42]))
 
     @mock.patch.object(JenkinsBase, 'get_data', mockGetData)
     def test_getitem(self):
@@ -165,14 +165,14 @@ class TestQueue(unittest.TestCase):
     def test_get_queue_item_for_job(self):
         item40 = self.q.get_queue_items_for_job('klscuimkqo')
         self.assertIsInstance(item40, list)
-        self.assertEquals(len(item40), 1)
+        self.assertEqual(len(item40), 1)
         self.assertIsInstance(item40[0], QueueItem)
 
 
     @mock.patch.object(JenkinsBase, 'get_data', mockGetData)
     def test_qi_get_parameters(self):
         qi = self.q[42]
-        self.assertEquals(qi.get_parameters(), {'name1': 'value1',
+        self.assertEqual(qi.get_parameters(), {'name1': 'value1',
                                                 'node': None})
 
 
index ac754d1603a10cf510e3fc2664e4216d46f322f6..7ff9728e52387cac677d34f81158adea27f0f4a5 100644 (file)
@@ -1,6 +1,4 @@
-from __future__ import print_function
-
-import mock
+from unittest import mock
 # To run unittests on python 2.6 please use unittest2 library
 try:
     import unittest2 as unittest
index 32fd3ec3ff2af61722cd2d6021c3d3782e6e27cd..c5ccb893dc7883ce4ed213347f8115c179289f5c 100644 (file)
@@ -1,4 +1,4 @@
-import mock
+from unittest import mock
 # To run unittests on python 2.6 please use unittest2 library
 try:
     import unittest2 as unittest
@@ -69,11 +69,11 @@ class TestResultSet(unittest.TestCase):
         with self.assertRaises(AttributeError):
             self.rs.id()
 
-        self.assertEquals(self.rs.name, 'Test Result for FooBuild')
+        self.assertEqual(self.rs.name, 'Test Result for FooBuild')
 
     def testBuildComponents(self):
-        self.assertTrue(self.rs.items())
-        for k, v in self.rs.items():
+        self.assertTrue(list(self.rs.items()))
+        for k, v in list(self.rs.items()):
             self.assertIsInstance(k, str)
             self.assertIsInstance(v, Result)
             self.assertIsInstance(v.identifier(), str)
index f574366f21d42334d25593e700852799877c411e..0d0d91c9139d3acc8720edc830268641b42733a2 100644 (file)
@@ -1,4 +1,4 @@
-import mock
+from unittest import mock
 # To run unittests on python 2.6 please use unittest2 library
 try:
     import unittest2 as unittest
@@ -82,22 +82,22 @@ class TestView(unittest.TestCase):
     def testName(self):
         with self.assertRaises(AttributeError):
             self.v.id()
-        self.assertEquals(self.v.name, 'FodFanFo')
+        self.assertEqual(self.v.name, 'FodFanFo')
 
     @mock.patch.object(JenkinsBase, '_poll')
     def test_iteritems(self, _poll):
         _poll.return_value = self.JOB_DATA
-        for job_name, job_obj in self.v.iteritems():
+        for job_name, job_obj in self.v.items():
             self.assertTrue(isinstance(job_obj, Job))
 
     def test_get_job_dict(self):
         jobs = self.v.get_job_dict()
-        self.assertEquals(jobs, {
+        self.assertEqual(jobs, {
             'foo': 'http://halob:8080/job/foo/',
             'test_jenkinsapi': 'http://halob:8080/job/test_jenkinsapi/'})
 
     def test_len(self):
-        self.assertEquals(len(self.v), 2)
+        self.assertEqual(len(self.v), 2)
 
     # We have to re-patch JenkinsBase here because by the time
     # it get to create Job, MagicMock will already expire
@@ -111,7 +111,7 @@ class TestView(unittest.TestCase):
         self.assertTrue(self.v.deleted)
 
     def test_get_job_url(self):
-        self.assertEquals(self.v.get_job_url('foo'), 'http://halob:8080/job/foo/')
+        self.assertEqual(self.v.get_job_url('foo'), 'http://halob:8080/job/foo/')
 
     def test_wrong_get_job_url(self):
         with self.assertRaises(NotFound):
@@ -153,7 +153,7 @@ class TestView(unittest.TestCase):
     def test_get_nested_view_dict(self):
         result = self.v.get_nested_view_dict()
         self.assertTrue(isinstance(result, dict))
-        self.assertEquals(len(result), 0)
+        self.assertEqual(len(result), 0)
 
 if __name__ == '__main__':
     unittest.main()
index 27acca408ab712450120c82b6486a851da7019c8..5f0da2acc7ef8eeec152e80a26a4625b1c2b3c4b 100644 (file)
@@ -35,7 +35,7 @@ class TestViews(unittest.TestCase):
 
         new_view = J.views.create('NewView')
         self.assertTrue(isinstance(new_view, View))
-        self.assertEquals(new_view.baseurl,
+        self.assertEqual(new_view.baseurl,
                           'http://localhost:8080/views/NewView')
 
     def test_create_existing_view(self):
index 785ff938fcffcd48a0f3a5900508956a2f90b96e..82b193964f9cde61ac573837e1e7b1455e335276 100644 (file)
@@ -1,7 +1,7 @@
 import os
 import time
 try:
-    import Queue
+    import queue
 except ImportError:
     import queue as Queue
 import random
@@ -14,7 +14,7 @@ import threading
 import subprocess
 from pkg_resources import resource_string
 try:
-    from urlparse import urlparse
+    from urllib.parse import urlparse
 except ImportError:
     from urllib.parse import urlparse
 
@@ -69,7 +69,7 @@ class JenkinsLancher(object):
         self.war_directory, self.war_filename = os.path.split(self.war_path)
         self.jenkins_home = tempfile.mkdtemp(prefix='jenkins-home-')
         self.jenkins_process = None
-        self.q = Queue.Queue()
+        self.q = queue.Queue()
         self.plugin_urls = plugin_urls or []
 
     def update_war(self):
@@ -168,7 +168,7 @@ class JenkinsLancher(object):
                     # Python 3.x
                     if isinstance(line, bytes):
                         line = line.decode('UTF-8')
-                except Queue.Empty:
+                except queue.Empty:
                     log.warn("Input ended unexpectedly")
                     break
                 else:
index f5be1ab8e215717a34276a4e8a325da75f073da8..986dd89e466e51b36607041026d72b6f4192ef6b 100644 (file)
@@ -1,18 +1,18 @@
-from __future__ import print_function
 
-import SimpleHTTPServer
-import SocketServer
+
+import http.server
+import socketserver
 import logging
 import cgi
 
 PORT = 8080
 
 
-class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
+class ServerHandler(http.server.SimpleHTTPRequestHandler):
 
     def do_GET(self):
         logging.error(self.headers)
-        SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
+        http.server.SimpleHTTPRequestHandler.do_GET(self)
 
     def do_POST(self):
         logging.error(self.headers)
@@ -24,11 +24,11 @@ class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
                      })
         for item in form.list:
             logging.error(item)
-        SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
+        http.server.SimpleHTTPRequestHandler.do_GET(self)
 
 Handler = ServerHandler
 
-httpd = SocketServer.TCPServer(("", PORT), Handler)
+httpd = socketserver.TCPServer(("", PORT), Handler)
 
 print("serving at port", PORT)
 httpd.serve_forever()
index 95d46ed75c44ff7be171e7bb6a6b35146c65f606..df1e92a9b85e35091a3c7907086a25e6a87673e7 100755 (executable)
@@ -1,7 +1,7 @@
-pip install wheel
-pip install mock
-pip install coverage
-pip install sphinx
+pip3 install wheel
+pip3 install mock
+pip3 install coverage
+pip3 install sphinx
 ant release
 git tag v`jenkinsapi_version`
 ant doc
diff --git a/requirements.txt b/requirements.txt
new file mode 100644 (file)
index 0000000..a5c7e95
--- /dev/null
@@ -0,0 +1,4 @@
+pytz>=2014.4
+requests>=2.3.0
+six>=1.10.0
+
index f0cc800d47e0e1378fe221756893e57185c17313..4fb8a15f7ea1555baefb1943e0696bb21542590a 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,3 +1,43 @@
+[metadata]
+name = jenkinsapi
+author = Salim Fadhley, Aleksey Maksimov
+author_email = salimfadhley@gmail.com, ctpeko3a@gmail.com
+summary = A Python API for accessing resources on a Jenkins continuous-integration server.
+description-file = README.rst
+license = MIT
+classifier = 
+       Development Status :: 4 - Beta
+       Environment :: Console
+       Intended Audience :: Developers
+       Intended Audience :: Information Technology
+       Intended Audience :: System Administrators
+       License :: OSI Approved :: MIT License
+       Natural Language :: English
+       Operating System :: OS Independent
+       Operating System :: OS Independent
+       Programming Language :: Python
+       Programming Language :: Python :: 2
+       Programming Language :: Python :: 2.7
+       Programming Language :: Python :: 3
+       Programming Language :: Python :: 3.4
+       Programming Language :: Python :: 3.5
+       Programming Language :: Python :: 3.6
+       Topic :: Software Development :: Testing
+       Topic :: Utilities
+
+[files]
+packages = 
+       jenkinsapi
+       jenkinsapi_utils
+
+[pbr]
+warnerrors = True
+
+[entry_points]
+console_scripts = 
+       jenkins_invoke=jenkinsapi.command_line.jenkins_invoke:main
+       jenkinsapi_version=jenkinsapi.command_line.jenkinsapi_version:main
+
 [build_sphinx]
 source-dir = doc/source
 build-dir = doc/build
@@ -6,7 +46,15 @@ all_files = 1
 [upload_sphinx]
 upload-dir = doc/build/html
 
-[nosetests]
-detailed-errors = 1
-with-coverage = 1
-cover-package = jenkinsapi
\ No newline at end of file
+[bdist_wheel]
+universal = 1
+
+[pycodestyle]
+exclude = .tox,doc/source/conf.py,build,.venv,.eggs
+max-line-length = 99
+
+[egg_info]
+tag_build = 
+tag_date = 0
+
+
index 765a57a13c915ff178d77b9f4cb9afe6a17e4c2f..8674709d253264a64aa2c175ba13b6cf10b10414 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,49 +1,7 @@
 from setuptools import setup
-import os
 
-PROJECT_ROOT, _ = os.path.split(__file__)
-REVISION = '0.2.26'
-PROJECT_NAME = 'JenkinsAPI'
-PROJECT_AUTHORS = "Salim Fadhley, Aleksey Maksimov"
-# Please see readme.rst for a complete list of contributors
-PROJECT_EMAILS = 'salimfadhley@gmail.com, ctpeko3a@gmail.com'
-PROJECT_URL = "https://github.com/salimfadhley/jenkinsapi"
-SHORT_DESCRIPTION = 'A Python API for accessing resources on a Jenkins continuous-integration server.'
-
-try:
-    DESCRIPTION = open(os.path.join(PROJECT_ROOT, "README.rst")).read()
-except IOError:
-    DESCRIPTION = SHORT_DESCRIPTION
-
-GLOBAL_ENTRY_POINTS = {
-    "console_scripts": ["jenkins_invoke=jenkinsapi.command_line.jenkins_invoke:main",
-                        "jenkinsapi_version=jenkinsapi.command_line.jenkinsapi_version:main"]
-}
 
 setup(
-    name=PROJECT_NAME.lower(),
-    version=REVISION,
-    author=PROJECT_AUTHORS,
-    author_email=PROJECT_EMAILS,
-    packages=['jenkinsapi', 'jenkinsapi.utils', 'jenkinsapi.command_line', 'jenkinsapi_tests'],
-    zip_safe=True,
-    include_package_data=False,
-    install_requires=['requests>=2.3.0', 'pytz>=2014.4'],
-    test_suite='nose.collector',
-    tests_require=['mock', 'nose', 'coverage', 'unittest2'],
-    entry_points=GLOBAL_ENTRY_POINTS,
-    url=PROJECT_URL,
-    description=SHORT_DESCRIPTION,
-    long_description=DESCRIPTION,
-    license='MIT',
-    classifiers=[
-        'Development Status :: 4 - Beta',
-        'Environment :: Console',
-        'Intended Audience :: Developers',
-        'License :: OSI Approved :: MIT License',
-        'Natural Language :: English',
-        'Operating System :: OS Independent',
-        'Programming Language :: Python :: 2.7',
-        'Topic :: Software Development :: Testing',
-    ],
-)
+    setup_requires=['pbr'],
+    pbr=True)
+