on xenial help sign in
Change check for str/basestring
8811130Christopher Lee
tests/autopilot/unity8/shell/tests/test_lock_screen.py+9−3
@@ -25,12 +25,18 @@ from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
25
25
26from autopilot.matchers import Eventually
26from autopilot.matchers import Eventually
27from autopilot.platform import model
27from autopilot.platform import model
28+import sys
28from testtools import skipUnless
29from testtools import skipUnless
29from testtools.matchers import Equals
30from testtools.matchers import Equals
30import logging
31import logging
31
32
32logger = logging.getLogger(__name__)
33logger = logging.getLogger(__name__)
33
34
35+# py2 compatible alias for py3
36+if sys.version >= '3':
37+ basestring = str
38+
39+
34class TestLockscreen(UnityTestCase):
40class TestLockscreen(UnityTestCase):
35
41
36 """Tests for the lock screen."""
42 """Tests for the lock screen."""
@@ -123,7 +129,7 @@ class TestLockscreen(UnityTestCase):
123
129
124 """
130 """
125
131
126− if not isinstance(code, str):
132+ if not isinstance(code, basestring):
127 raise TypeError(
133 raise TypeError(
128 "'code' parameter must be a string, not %r."
134 "'code' parameter must be a string, not %r."
129 % type(passphrase)
135 % type(passphrase)
@@ -143,7 +149,7 @@ class TestLockscreen(UnityTestCase):
143 :raises: TypeError if passphrase is not a string.
149 :raises: TypeError if passphrase is not a string.
144
150
145 """
151 """
146− if not isinstance(passphrase, str):
152+ if not isinstance(passphrase, basestring):
147 raise TypeError(
153 raise TypeError(
148 "'passphrase' parameter must be a string, not %r."
154 "'passphrase' parameter must be a string, not %r."
149 % type(passphrase)
155 % type(passphrase)
@@ -165,7 +171,7 @@ class TestLockscreen(UnityTestCase):
165 :raises: TypeError if passphrase is not a string.
171 :raises: TypeError if passphrase is not a string.
166
172
167 """
173 """
168− if not isinstance(passphrase, str):
174+ if not isinstance(passphrase, basestring):
169 raise TypeError(
175 raise TypeError(
170 "'passphrase' parameter must be a string, not %r."
176 "'passphrase' parameter must be a string, not %r."
171 % type(passphrase)
177 % type(passphrase)