Revert back changes to import unittest2 for py26

This commit is contained in:
Jisi Liu 2015-10-05 16:08:22 -07:00
parent a783eaf37f
commit dbea00ae88
16 changed files with 64 additions and 26 deletions

View file

@ -34,7 +34,10 @@
__author__ = 'matthewtoia@google.com (Matt Toia)'
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf import descriptor_pb2
from google.protobuf.internal import factory_test2_pb2
from google.protobuf import descriptor_database

View file

@ -36,7 +36,10 @@ __author__ = 'matthewtoia@google.com (Matt Toia)'
import os
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf import unittest_pb2
from google.protobuf import descriptor_pb2
from google.protobuf.internal import api_implementation

View file

@ -36,7 +36,10 @@ __author__ = 'robinson@google.com (Will Robinson)'
import sys
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_pb2
@ -391,7 +394,7 @@ class DescriptorTest(unittest.TestCase):
self.assertEqual(self.my_file.name, 'some/filename/some.proto')
self.assertEqual(self.my_file.package, 'protobuf_unittest')
@test_util.skipIf(
@unittest.skipIf(
api_implementation.Type() != 'cpp' or api_implementation.Version() != 2,
'Immutability of descriptors is only enforced in v2 implementation')
def testImmutableCppDescriptor(self):

View file

@ -41,7 +41,10 @@ further ensures that we can use Python protocol message objects as we expect.
__author__ = 'robinson@google.com (Will Robinson)'
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf.internal import test_bad_identifiers_pb2
from google.protobuf import unittest_custom_options_pb2
from google.protobuf import unittest_import_pb2

View file

@ -38,7 +38,10 @@ import json
import math
import sys
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf import json_format
from google.protobuf.util import json_format_proto3_pb2

View file

@ -34,7 +34,10 @@
__author__ = 'matthewtoia@google.com (Matt Toia)'
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf import descriptor_pb2
from google.protobuf.internal import factory_test1_pb2
from google.protobuf.internal import factory_test2_pb2

View file

@ -52,7 +52,10 @@ import pickle
import six
import sys
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf.internal import _parameterized
from google.protobuf import map_unittest_pb2
from google.protobuf import unittest_pb2

View file

@ -37,7 +37,10 @@ try:
except ImportError:
from ordereddict import OrderedDict #PY26
import collections
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor_pool
from google.protobuf import proto_builder

View file

@ -41,7 +41,10 @@ import operator
import six
import struct
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
@ -1623,7 +1626,7 @@ class ReflectionTest(unittest.TestCase):
self.assertFalse(proto.IsInitialized(errors))
self.assertEqual(errors, ['a', 'b', 'c'])
@test_util.skipIf(
@unittest.skipIf(
api_implementation.Type() != 'cpp' or api_implementation.Version() != 2,
'Errors are only available from the most recent C++ implementation.')
def testFileDescriptorErrors(self):
@ -2822,7 +2825,7 @@ class OptionsTest(unittest.TestCase):
class ClassAPITest(unittest.TestCase):
@test_util.skipIf(
@unittest.skipIf(
api_implementation.Type() == 'cpp' and api_implementation.Version() == 2,
'C++ implementation requires a call to MakeDescriptor()')
def testMakeClassWithNestedDescriptor(self):

View file

@ -34,7 +34,10 @@
__author__ = 'petar@google.com (Petar Petrov)'
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf import unittest_pb2
from google.protobuf import service_reflection
from google.protobuf import service

View file

@ -32,7 +32,10 @@
"""Tests for google.protobuf.symbol_database."""
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf import unittest_pb2
from google.protobuf import descriptor
from google.protobuf import symbol_database

View file

@ -38,13 +38,6 @@ __author__ = 'robinson@google.com (Will Robinson)'
import os.path
import sys
# PY2.6 compatible skipIf
if sys.version_info < (2, 7):
from unittest2 import skipIf
else:
from unittest import skipIf
from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_pb2
from google.protobuf import descriptor_pb2

View file

@ -32,7 +32,10 @@
"""Tests for google.protobuf.text_encoding."""
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf import text_encoding
TEST_VALUES = [

View file

@ -39,7 +39,10 @@ import re
import six
import string
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf.internal import _parameterized
from google.protobuf import map_unittest_pb2

View file

@ -35,7 +35,10 @@
__author__ = 'bohdank@google.com (Bohdan Koval)'
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf import unittest_mset_pb2
from google.protobuf import unittest_pb2
from google.protobuf import unittest_proto3_arena_pb2
@ -48,7 +51,7 @@ from google.protobuf.internal import type_checkers
def SkipIfCppImplementation(func):
return test_util.skipIf(
return unittest.skipIf(
api_implementation.Type() == 'cpp' and api_implementation.Version() == 2,
'C++ implementation does not expose unknown fields to Python')(func)

View file

@ -34,7 +34,10 @@
__author__ = 'robinson@google.com (Will Robinson)'
import unittest
try:
import unittest2 as unittest
except ImportError:
import unittest
from google.protobuf import message
from google.protobuf.internal import wire_format