aboutsummaryrefslogtreecommitdiffstats
path: root/xtesting/core
diff options
context:
space:
mode:
authorCedric Ollivier <cedric.ollivier@orange.com>2021-06-03 06:16:49 +0000
committerGerrit Code Review <gerrit@opnfv.org>2021-06-03 06:16:49 +0000
commitec6921039af3b016eecc6e609f2554aea0f81e2c (patch)
tree4d2df62475e73a563e572180a13dec3b5e1b994e /xtesting/core
parent454bef238020d8ac0e986807f34dfc140362b629 (diff)
parenta656fd764b0a608caaf198bfa9685a09a7eaca16 (diff)
Merge "Drop six"
Diffstat (limited to 'xtesting/core')
-rw-r--r--xtesting/core/behaveframework.py8
-rw-r--r--xtesting/core/campaign.py10
-rw-r--r--xtesting/core/feature.py4
-rw-r--r--xtesting/core/mts.py20
-rw-r--r--xtesting/core/robotframework.py2
-rw-r--r--xtesting/core/testcase.py21
-rw-r--r--xtesting/core/unit.py5
7 files changed, 28 insertions, 42 deletions
diff --git a/xtesting/core/behaveframework.py b/xtesting/core/behaveframework.py
index dba556f4..e288fff8 100644
--- a/xtesting/core/behaveframework.py
+++ b/xtesting/core/behaveframework.py
@@ -16,7 +16,6 @@ import os
import time
import json
-import six
from behave.__main__ import main as behave_main
@@ -92,10 +91,9 @@ class BehaveFramework(testcase.TestCase):
config = ['--tags='+','.join(tags),
'--junit', '--junit-directory={}'.format(self.res_dir),
'--format=json', '--outfile={}'.format(self.json_file)]
- if six.PY3:
- html_file = os.path.join(self.res_dir, 'output.html')
- config += ['--format=behave_html_formatter:HTMLFormatter',
- '--outfile={}'.format(html_file)]
+ html_file = os.path.join(self.res_dir, 'output.html')
+ config += ['--format=behave_html_formatter:HTMLFormatter',
+ '--outfile={}'.format(html_file)]
if kwargs.get("console", False):
config += ['--format=pretty', '--outfile=-']
for feature in suites:
diff --git a/xtesting/core/campaign.py b/xtesting/core/campaign.py
index 51a145c1..58747681 100644
--- a/xtesting/core/campaign.py
+++ b/xtesting/core/campaign.py
@@ -17,12 +17,12 @@ import os
import re
import zipfile
+from urllib.parse import urlparse
import boto3
from boto3.s3.transfer import TransferConfig
import botocore
import pkg_resources
import requests
-from six.moves import urllib
from xtesting.core import testcase
from xtesting.utils import env
@@ -120,9 +120,9 @@ class Campaign():
multipart_threshold = 5 * 1024 ** 5 if "google" in os.environ[
"S3_ENDPOINT_URL"] else 8 * 1024 * 1024
config = TransferConfig(multipart_threshold=multipart_threshold)
- bucket_name = urllib.parse.urlparse(dst_s3_url).netloc
+ bucket_name = urlparse(dst_s3_url).netloc
s3path = re.search(
- '^/*(.*)/*$', urllib.parse.urlparse(dst_s3_url).path).group(1)
+ '^/*(.*)/*$', urlparse(dst_s3_url).path).group(1)
prefix = os.path.join(s3path, build_tag)
# pylint: disable=no-member
for s3_object in b3resource.Bucket(bucket_name).objects.filter(
@@ -183,9 +183,9 @@ class Campaign():
multipart_threshold = 5 * 1024 ** 5 if "google" in os.environ[
"S3_ENDPOINT_URL"] else 8 * 1024 * 1024
config = TransferConfig(multipart_threshold=multipart_threshold)
- bucket_name = urllib.parse.urlparse(dst_s3_url).netloc
+ bucket_name = urlparse(dst_s3_url).netloc
mime_type = mimetypes.guess_type('{}.zip'.format(build_tag))
- path = urllib.parse.urlparse(dst_s3_url).path.strip("/")
+ path = urlparse(dst_s3_url).path.strip("/")
# pylint: disable=no-member
b3resource.Bucket(bucket_name).upload_file(
'{}.zip'.format(build_tag),
diff --git a/xtesting/core/feature.py b/xtesting/core/feature.py
index 3b2a19f2..f92858bd 100644
--- a/xtesting/core/feature.py
+++ b/xtesting/core/feature.py
@@ -20,15 +20,13 @@ import subprocess
import sys
import time
-import six
from xtesting.core import testcase
__author__ = ("Serena Feng <feng.xiaowei@zte.com.cn>, "
"Cedric Ollivier <cedric.ollivier@orange.com>")
-@six.add_metaclass(abc.ABCMeta)
-class Feature(testcase.TestCase):
+class Feature(testcase.TestCase, metaclass=abc.ABCMeta):
"""Base model for single feature."""
__logger = logging.getLogger(__name__)
diff --git a/xtesting/core/mts.py b/xtesting/core/mts.py
index 0530b84c..f1cf80ac 100644
--- a/xtesting/core/mts.py
+++ b/xtesting/core/mts.py
@@ -21,7 +21,6 @@ import time
from lxml import etree
import prettytable
-import six
from xtesting.core import testcase
@@ -241,17 +240,14 @@ class MTSLauncher(testcase.TestCase):
if console:
sys.stdout.write(line.decode("utf-8"))
f_stdout.write(line.decode("utf-8"))
- if six.PY3:
- try:
- process.wait(timeout=max_duration)
- except subprocess.TimeoutExpired:
- process.kill()
- self.__logger.info(
- "Killing MTS process after %d second(s).",
- max_duration)
- return 3
- else:
- process.wait()
+ try:
+ process.wait(timeout=max_duration)
+ except subprocess.TimeoutExpired:
+ process.kill()
+ self.__logger.info(
+ "Killing MTS process after %d second(s).",
+ max_duration)
+ return 3
with open(self.result_file, 'r') as f_stdin:
self.__logger.debug("$ %s\n%s", cmd, f_stdin.read().rstrip())
return process.returncode
diff --git a/xtesting/core/robotframework.py b/xtesting/core/robotframework.py
index a973e9a2..64ee352c 100644
--- a/xtesting/core/robotframework.py
+++ b/xtesting/core/robotframework.py
@@ -14,12 +14,12 @@ from __future__ import division
import logging
import os
+from io import StringIO
import robot.api
from robot.errors import RobotError
from robot.reporting import resultwriter
import robot.run
from robot.utils.robottime import timestamp_to_secs
-from six import StringIO
from xtesting.core import testcase
diff --git a/xtesting/core/testcase.py b/xtesting/core/testcase.py
index 08ce426b..15936f1d 100644
--- a/xtesting/core/testcase.py
+++ b/xtesting/core/testcase.py
@@ -16,15 +16,13 @@ import logging
import mimetypes
import os
import re
-import sys
+from urllib.parse import urlparse
import boto3
from boto3.s3.transfer import TransferConfig
import botocore
import prettytable
import requests
-import six
-from six.moves import urllib
from xtesting.utils import decorators
from xtesting.utils import env
@@ -33,8 +31,7 @@ from xtesting.utils import constants
__author__ = "Cedric Ollivier <cedric.ollivier@orange.com>"
-@six.add_metaclass(abc.ABCMeta)
-class TestCase():
+class TestCase(metaclass=abc.ABCMeta):
# pylint: disable=too-many-instance-attributes
"""Base model for single test case."""
@@ -238,7 +235,7 @@ class TestCase():
url, data=json.dumps(data, sort_keys=True),
headers=self.headers)
req.raise_for_status()
- if urllib.parse.urlparse(url).scheme != "file":
+ if urlparse(url).scheme != "file":
# href must be postprocessed as OPNFV testapi is misconfigured
# (localhost is returned)
uid = re.sub(r'^.*/api/v1/results/*', '', req.json()["href"])
@@ -289,7 +286,7 @@ class TestCase():
multipart_threshold = 5 * 1024 ** 5 if "google" in os.environ[
"S3_ENDPOINT_URL"] else 8 * 1024 * 1024
config = TransferConfig(multipart_threshold=multipart_threshold)
- bucket_name = urllib.parse.urlparse(dst_s3_url).netloc
+ bucket_name = urlparse(dst_s3_url).netloc
try:
b3resource.meta.client.head_bucket(Bucket=bucket_name)
except botocore.exceptions.ClientError as exc:
@@ -298,12 +295,10 @@ class TestCase():
# pylint: disable=no-member
b3resource.create_bucket(Bucket=bucket_name)
else:
- typ, value, traceback = sys.exc_info()
- six.reraise(typ, value, traceback)
- except Exception: # pylint: disable=broad-except
- typ, value, traceback = sys.exc_info()
- six.reraise(typ, value, traceback)
- path = urllib.parse.urlparse(dst_s3_url).path.strip("/")
+ raise exc
+ except Exception as exc: # pylint: disable=broad-except
+ raise exc
+ path = urlparse(dst_s3_url).path.strip("/")
dst_http_url = os.environ["HTTP_DST_URL"]
output_str = "\n"
self.details["links"] = []
diff --git a/xtesting/core/unit.py b/xtesting/core/unit.py
index 877cd073..9d549a2d 100644
--- a/xtesting/core/unit.py
+++ b/xtesting/core/unit.py
@@ -10,7 +10,7 @@
"""Define the parent class to run unittest.TestSuite as TestCase."""
from __future__ import division
-
+from io import BytesIO
import logging
import os
import shutil
@@ -19,7 +19,6 @@ import time
import unittest
from subunit.run import SubunitTestRunner
-import six
from xtesting.core import testcase
@@ -112,7 +111,7 @@ class Suite(testcase.TestCase):
self.start_time = time.time()
if not os.path.isdir(self.res_dir):
os.makedirs(self.res_dir)
- stream = six.BytesIO()
+ stream = BytesIO()
result = SubunitTestRunner(
stream=stream, verbosity=2).run(self.suite).decorated
self.generate_stats(stream)