Skip to content

Commit a0971af

Browse files
committed
Make integration for LC Python 2 and 3 compatible
Signed-off-by: Martin Styk <mart.styk@gmail.com>
1 parent 185db0c commit a0971af

4 files changed

Lines changed: 59 additions & 52 deletions

File tree

IntegrationTests/src/bkr/inttest/labcontroller/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
import os
99
import shutil
1010
import signal
11-
from socket import gethostname
12-
from urlparse import urlparse, urlunparse
1311
from bkr.labcontroller.config import load_conf, get_conf
1412
from turbogears.database import session
1513
from bkr.server.model import LabController, Watchdog, Recipe, RecipeSet, \
1614
System, SystemStatus
1715
from bkr.inttest import data_setup, Process, DatabaseTestCase
16+
17+
1818
log = logging.getLogger(__name__)
1919

2020
# XXX this should be inside setup_package, but lots of code in

IntegrationTests/src/bkr/inttest/labcontroller/test_distro_import.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
import subprocess
1010
import json
1111
import pkg_resources
12-
import urlparse
13-
from copy import copy, deepcopy
12+
from copy import deepcopy
1413
from bkr.inttest import Process
1514
from bkr.inttest.labcontroller import LabControllerTestCase
1615
from bkr.server.model import OSMajor
1716
from turbogears.database import session
1817

18+
from six.moves import urllib
19+
20+
1921
_current_dir = os.path.dirname(__file__)
2022
_compose_test_dir = pkg_resources.resource_filename('bkr.inttest.labcontroller', 'compose_layout')
2123
_git_root_dir = os.path.join(_current_dir, '..', '..', '..', '..', '..')
@@ -1175,7 +1177,7 @@ def setUp(self):
11751177
u"type": u"initrd"
11761178
}
11771179
],
1178-
u"kernel_options": u" inst.stage2={}".format(urlparse.urljoin(
1180+
u"kernel_options": u" inst.stage2={}".format(urllib.parse.urljoin(
11791181
self.distro_url, u'RHVH4/RHVH-4.3-20200323.0/compose/RHVH/x86_64/os')),
11801182
u"kernel_options_post": None,
11811183
u"ks_meta": u" autopart_type=thinp liveimg=Packages/redhat-virtualization-host-image-update-1.0.0-1.noarch.rpm ks_keyword=inst.ks",
@@ -1199,7 +1201,7 @@ def setUp(self):
11991201
],
12001202
u"tree_build_time": u"1584961599",
12011203
u"urls": [
1202-
u"{}".format(urlparse.urljoin(self.distro_url, u'RHVH4/RHVH-4.3-20200323.0/compose/RHVH/x86_64/os/'))
1204+
u"{}".format(urllib.parse.urljoin(self.distro_url, u'RHVH4/RHVH-4.3-20200323.0/compose/RHVH/x86_64/os/'))
12031205
],
12041206
u"variant": u"RHVH"
12051207
}
@@ -1208,7 +1210,7 @@ def _run_import(self, import_args):
12081210
p = subprocess.Popen(import_args,
12091211
stdout=subprocess.PIPE,
12101212
stderr=subprocess.PIPE,
1211-
env=dict(os.environ.items() + [('PYTHONUNBUFFERED', '1')]))
1213+
env=dict(list(os.environ.items()) + [('PYTHONUNBUFFERED', '1')]))
12121214
stdout, stderr = p.communicate()
12131215
if p.returncode:
12141216
raise TreeImportError(import_args, p.returncode, stderr)
@@ -1220,7 +1222,7 @@ def dry_run_import_trees(self, additional_import_args):
12201222
trees, stderr = self._run_import(
12211223
['python', _command, '--debug', '--json', '--dry-run']
12221224
+ additional_import_args)
1223-
print stderr
1225+
print(stderr)
12241226
# check logging is working correctly
12251227
self.assertIn('Dry Run only', stderr)
12261228
self.assertIn('Attempting to import: ', stderr)
@@ -1559,6 +1561,6 @@ def test_rhel8_partner_import(self):
15591561
self.assertItemsEqual(trees, [self.x86_64_rhel8_partner])
15601562

15611563
def test_rhvh43_import(self):
1562-
trees = self.dry_run_import_trees(['{}'.format(urlparse.urljoin(self.distro_url,
1564+
trees = self.dry_run_import_trees(['{}'.format(urllib.parse.urljoin(self.distro_url,
15631565
'RHVH4/RHVH-4.3-20200323.0/compose'))])
15641566
self.assertItemsEqual(trees, [self.x86_64_rhvh43])

IntegrationTests/src/bkr/inttest/labcontroller/test_provision.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
import pkg_resources
1010
from turbogears.database import session
1111
from unittest import SkipTest, TestCase
12-
from xmlrpclib import _Method
1312
from bkr.server.model import PowerType, CommandStatus, System, User, SystemStatus
1413
from bkr.labcontroller.config import get_conf
1514
from bkr.labcontroller.provision import CommandQueuePoller
1615
from bkr.inttest import data_setup, Process
1716
from bkr.inttest.assertions import wait_for_condition
1817
from bkr.inttest.labcontroller import LabControllerTestCase, processes, daemons_running_externally
1918

19+
from six.moves.xmlrpc_client import _Method
20+
21+
2022
log = logging.getLogger(__name__)
2123

2224

0 commit comments

Comments
 (0)