Skip to content

Commit a7e1cfd

Browse files
committed
Remove support for python 2
1 parent d787215 commit a7e1cfd

File tree

4 files changed

+10
-46
lines changed

4 files changed

+10
-46
lines changed

setup.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@
99
except ImportError:
1010
from distutils.core import setup
1111

12-
PY3 = sys.version_info > (3,)
13-
1412
CLASSIFIERS = """
1513
Development Status :: 5 - Production/Stable
1614
License :: OSI Approved :: MIT License
1715
Operating System :: OS Independent
1816
Programming Language :: Python
19-
Programming Language :: Python :: 2
20-
Programming Language :: Python :: 2.7
2117
Programming Language :: Python :: 3
2218
Programming Language :: Python :: 3.6
2319
Programming Language :: Python :: 3.7
@@ -26,8 +22,7 @@
2622
Topic :: Software Development :: Testing
2723
"""[1:-1]
2824

29-
TEST_REQUIRE = ['robotframework>=3.2.1', 'pytest', 'flask', 'six', 'coverage', 'flake8'] if PY3 \
30-
else ['robotframework>=3.2.1', 'pytest', 'flask', 'coverage', 'flake8', 'mock']
25+
TEST_REQUIRE = ['robotframework>=3.2.1', 'pytest', 'flask', 'six', 'coverage', 'flake8']
3126

3227
VERSION = None
3328
version_file = join(dirname(abspath(__file__)), 'src', 'RequestsLibrary', 'version.py')

src/RequestsLibrary/SessionKeywords.py

+3-15
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from robot.utils.asserts import assert_equal
1212

1313
from RequestsLibrary import utils
14-
from RequestsLibrary.compat import httplib, PY3, RetryAdapter
14+
from RequestsLibrary.compat import httplib, RetryAdapter
1515
from .RequestsKeywords import RequestsKeywords
1616
from RequestsLibrary.exceptions import InvalidResponse, InvalidExpectedStatus
1717
from RequestsLibrary.utils import is_string_type
@@ -602,20 +602,8 @@ def _capture_output(self):
602602
def _print_debug(self):
603603
if self.debug >= 1:
604604
sys.stdout = sys.__stdout__ # Restore stdout
605-
if PY3:
606-
debug_info = ''.join(
607-
self.http_log.content).replace(
608-
'\\r',
609-
'').replace(
610-
'\'',
611-
'')
612-
else:
613-
debug_info = ''.join(
614-
self.http_log.content).replace(
615-
'\\r',
616-
'').decode('string_escape').replace(
617-
'\'',
618-
'')
605+
debug_info = ''.join(
606+
self.http_log.content).replace('\\r','').replace('\'','')
619607

620608
# Remove empty lines
621609
debug_info = "\n".join(

src/RequestsLibrary/compat.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@
22
import sys
33
from requests.packages.urllib3.util import Retry
44

5-
PY3 = sys.version_info > (3,)
6-
7-
if PY3:
8-
import http.client as httplib # noqa
9-
from urllib.parse import urlencode # noqa
10-
from urllib.parse import urljoin # noqa
11-
else:
12-
import httplib # noqa
13-
from urllib import urlencode # noqa
14-
from urlparse import urljoin # noqa
15-
5+
import http.client as httplib # noqa
6+
from urllib.parse import urlencode # noqa
7+
from urllib.parse import urljoin # noqa
168

179
class RetryAdapter(Retry):
1810

src/RequestsLibrary/utils.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from requests.structures import CaseInsensitiveDict
77
from robot.api import logger
88

9-
from RequestsLibrary.compat import urlencode, PY3
9+
from RequestsLibrary.compat import urlencode
1010
from RequestsLibrary.exceptions import UnknownStatusError
1111

1212

@@ -74,20 +74,10 @@ def json_pretty_print(content):
7474

7575

7676
def is_string_type(data):
77-
if PY3 and isinstance(data, str):
78-
return True
79-
elif not PY3 and isinstance(data, unicode): # noqa
80-
return True
81-
return False
82-
77+
return isinstance(data, str)
8378

8479
def is_file_descriptor(fd):
85-
if PY3 and isinstance(fd, io.IOBase):
86-
return True
87-
if not PY3 and isinstance(fd, file): # noqa
88-
return True
89-
return False
90-
80+
return isinstance(fd, io.IOBase)
9181

9282
def utf8_urlencode(data):
9383
if is_string_type(data):
@@ -103,7 +93,6 @@ def utf8_urlencode(data):
10393
utf8_data[k] = v
10494
return urlencode(utf8_data)
10595

106-
10796
def format_data_according_to_header(session, data, headers):
10897
# when data is an open file descriptor we ignore it
10998
if is_file_descriptor(data):

0 commit comments

Comments
 (0)