summaryrefslogtreecommitdiffstats
path: root/lldb/third_party
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-11-03 21:37:42 +0000
committerZachary Turner <zturner@google.com>2015-11-03 21:37:42 +0000
commit46f1784bac7f8388c4a8185801c815d24dd0210f (patch)
tree94c409e7f574f3f4ea0e98fd8f145c9de1be45aa /lldb/third_party
parentbac6e4f75b7fe4c29fcad12cb08dc2bfb82bde13 (diff)
downloadbcm5719-llvm-46f1784bac7f8388c4a8185801c815d24dd0210f.tar.gz
bcm5719-llvm-46f1784bac7f8388c4a8185801c815d24dd0210f.zip
Python 3 - Fix checking of string types in unittest2 module.
This patch actually introduces a dependency from unittest2 to six. This should be ok since both packages are in our own repo, and we assume a sys.path of the top-level script that can find the third party packages. So unittest2 should be able to find six. llvm-svn: 251983
Diffstat (limited to 'lldb/third_party')
-rw-r--r--lldb/third_party/Python/module/unittest2/unittest2/case.py16
-rw-r--r--lldb/third_party/Python/module/unittest2/unittest2/main.py3
-rw-r--r--lldb/third_party/Python/module/unittest2/unittest2/suite.py3
-rw-r--r--lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py3
-rw-r--r--lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py3
5 files changed, 17 insertions, 11 deletions
diff --git a/lldb/third_party/Python/module/unittest2/unittest2/case.py b/lldb/third_party/Python/module/unittest2/unittest2/case.py
index 485cef09c22..68a9a7a42d1 100644
--- a/lldb/third_party/Python/module/unittest2/unittest2/case.py
+++ b/lldb/third_party/Python/module/unittest2/unittest2/case.py
@@ -7,6 +7,8 @@ import re
import unittest
import warnings
+import six
+
from unittest2 import result
from unittest2.util import (
safe_repr, safe_str, strclass,
@@ -137,7 +139,7 @@ class _AssertRaisesContext(object):
return True
expected_regexp = self.expected_regexp
- if isinstance(expected_regexp, basestring):
+ if isinstance(expected_regexp, six.string_types):
expected_regexp = re.compile(expected_regexp)
if not expected_regexp.search(str(exc_value)):
raise self.failureException('"%s" does not match "%s"' %
@@ -156,7 +158,7 @@ class _TypeEqualityDict(object):
def __getitem__(self, key):
value = self._store[key]
- if isinstance(value, basestring):
+ if isinstance(value, six.string_types):
return getattr(self.testcase, value)
return value
@@ -940,9 +942,9 @@ class TestCase(unittest.TestCase):
def assertMultiLineEqual(self, first, second, msg=None):
"""Assert that two multi-line strings are equal."""
- self.assert_(isinstance(first, basestring), (
+ self.assert_(isinstance(first, six.string_types), (
'First argument is not a string'))
- self.assert_(isinstance(second, basestring), (
+ self.assert_(isinstance(second, six.string_types), (
'Second argument is not a string'))
if first != second:
@@ -1018,7 +1020,7 @@ class TestCase(unittest.TestCase):
try:
callable_obj(*args, **kwargs)
except expected_exception as exc_value:
- if isinstance(expected_regexp, basestring):
+ if isinstance(expected_regexp, six.string_types):
expected_regexp = re.compile(expected_regexp)
if not expected_regexp.search(str(exc_value)):
raise self.failureException('"%s" does not match "%s"' %
@@ -1033,7 +1035,7 @@ class TestCase(unittest.TestCase):
def assertRegexpMatches(self, text, expected_regexp, msg=None):
"""Fail the test unless the text matches the regular expression."""
- if isinstance(expected_regexp, basestring):
+ if isinstance(expected_regexp, six.string_types):
expected_regexp = re.compile(expected_regexp)
if not expected_regexp.search(text):
msg = msg or "Regexp didn't match"
@@ -1042,7 +1044,7 @@ class TestCase(unittest.TestCase):
def assertNotRegexpMatches(self, text, unexpected_regexp, msg=None):
"""Fail the test if the text matches the regular expression."""
- if isinstance(unexpected_regexp, basestring):
+ if isinstance(unexpected_regexp, six.string_types):
unexpected_regexp = re.compile(unexpected_regexp)
match = unexpected_regexp.search(text)
if match:
diff --git a/lldb/third_party/Python/module/unittest2/unittest2/main.py b/lldb/third_party/Python/module/unittest2/unittest2/main.py
index c0b71ef6b83..d74b01f9ac2 100644
--- a/lldb/third_party/Python/module/unittest2/unittest2/main.py
+++ b/lldb/third_party/Python/module/unittest2/unittest2/main.py
@@ -3,6 +3,7 @@
import sys
import os
import types
+import six
from unittest2 import loader, runner
try:
@@ -76,7 +77,7 @@ class TestProgram(object):
argv=None, testRunner=None,
testLoader=loader.defaultTestLoader, exit=True,
verbosity=1, failfast=None, catchbreak=None, buffer=None):
- if isinstance(module, basestring):
+ if isinstance(module, six.string_types):
self.module = __import__(module)
for part in module.split('.')[1:]:
self.module = getattr(self.module, part)
diff --git a/lldb/third_party/Python/module/unittest2/unittest2/suite.py b/lldb/third_party/Python/module/unittest2/unittest2/suite.py
index da97f5bf8d2..9fda66aa09e 100644
--- a/lldb/third_party/Python/module/unittest2/unittest2/suite.py
+++ b/lldb/third_party/Python/module/unittest2/unittest2/suite.py
@@ -3,6 +3,7 @@
import sys
import unittest
from unittest2 import case, util
+import six
__unittest = True
@@ -48,7 +49,7 @@ class BaseTestSuite(unittest.TestSuite):
self._tests.append(test)
def addTests(self, tests):
- if isinstance(tests, basestring):
+ if isinstance(tests, six.string_types):
raise TypeError("tests must be an iterable of tests, not a string")
for test in tests:
self.addTest(test)
diff --git a/lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py b/lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
index 2e670d7b2cf..5f310ecb046 100644
--- a/lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
+++ b/lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
@@ -1,6 +1,7 @@
import difflib
import pprint
import re
+import six
from copy import deepcopy
@@ -502,7 +503,7 @@ class Test_TestCase(unittest2.TestCase, EqualityMixin, HashingMixin):
def runTest(self):
pass
- self.assertIsInstance(Foo().id(), basestring)
+ self.assertIsInstance(Foo().id(), six.string_types)
# "If result is omitted or None, a temporary result object is created
# and used, but is not made available to the caller. As TestCase owns the
diff --git a/lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py b/lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py
index 295aec37fdc..263aed5a9bf 100644
--- a/lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py
+++ b/lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py
@@ -1,4 +1,5 @@
import unittest2
+import six
from unittest2.test.support import LoggingResult
@@ -124,7 +125,7 @@ class Test_FunctionTestCase(unittest2.TestCase):
def test_id(self):
test = unittest2.FunctionTestCase(lambda: None)
- self.assertIsInstance(test.id(), basestring)
+ self.assertIsInstance(test.id(), six.string_types)
# "Returns a one-line description of the test, or None if no description
# has been provided. The default implementation of this method returns
OpenPOWER on IntegriCloud