From d065864e4bfee4073fa6a2fc8778d3f062fd45d0 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Thu, 29 Jun 2017 15:39:14 +0800 Subject: [PATCH] change method of checking python version --- ate/response.py | 6 +----- ate/utils.py | 5 +++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ate/response.py b/ate/response.py index 752d2348..dc0cb3f6 100644 --- a/ate/response.py +++ b/ate/response.py @@ -1,9 +1,5 @@ from ate import utils, exception -try: - basestring # Python 2.x -except NameError: - basestring = str # Python 3.x class ResponseObject(object): @@ -40,7 +36,7 @@ class ResponseObject(object): extract_binds_dict = {} for key, value in extract_binds.items(): - if not isinstance(value, basestring): + if not isinstance(value, utils.string_type): raise exception.ParamsError("invalid extract_binds!") try: diff --git a/ate/utils.py b/ate/utils.py index e3a0b86e..0f5d5190 100644 --- a/ate/utils.py +++ b/ate/utils.py @@ -9,9 +9,10 @@ import yaml from ate.exception import ParamsError try: - assert bytes is str + string_type = basestring PYTHON_VERSION = 2 -except AssertionError: +except NameError: + string_type = str PYTHON_VERSION = 3