Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
9f42f5f4
Commit
9f42f5f4
authored
Jan 13, 2015
by
Tamir Duberstein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PYTHON] Drop dependency on 'google.apputils'.
Use stdlib's 'unittest' instead.
parent
dab96f19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
101 additions
and
100 deletions
+101
-100
.travis.yml
.travis.yml
+2
-2
README.md
python/README.md
+2
-2
_parameterized.py
python/google/protobuf/internal/_parameterized.py
+1
-3
descriptor_database_test.py
python/google/protobuf/internal/descriptor_database_test.py
+4
-3
descriptor_pool_test.py
python/google/protobuf/internal/descriptor_pool_test.py
+3
-4
descriptor_test.py
python/google/protobuf/internal/descriptor_test.py
+7
-7
generator_test.py
python/google/protobuf/internal/generator_test.py
+6
-5
message_factory_test.py
python/google/protobuf/internal/message_factory_test.py
+12
-10
message_test.py
python/google/protobuf/internal/message_test.py
+5
-6
proto_builder_test.py
python/google/protobuf/internal/proto_builder_test.py
+3
-3
reflection_test.py
python/google/protobuf/internal/reflection_test.py
+14
-14
service_reflection_test.py
python/google/protobuf/internal/service_reflection_test.py
+4
-3
symbol_database_test.py
python/google/protobuf/internal/symbol_database_test.py
+4
-3
text_encoding_test.py
python/google/protobuf/internal/text_encoding_test.py
+4
-3
text_format_test.py
python/google/protobuf/internal/text_format_test.py
+12
-12
unknown_fields_test.py
python/google/protobuf/internal/unknown_fields_test.py
+9
-8
wire_format_test.py
python/google/protobuf/internal/wire_format_test.py
+4
-3
setup.py
python/setup.py
+1
-6
arena_nc_test.py
src/google/protobuf/arena_nc_test.py
+4
-3
No files found.
.travis.yml
View file @
9f42f5f4
...
...
@@ -11,9 +11,9 @@ script:
-
./autogen.sh && ./configure && make -j2
-
cd java && mvn test && cd ..
-
cd javanano && mvn test && cd ..
-
cd python && python setup.py build && python setup.py
google_
test && cd ..
-
cd python && python setup.py build && python setup.py test && cd ..
-
export LD_LIBRARY_PATH=../src/.libs
-
cd python && python setup.py build --cpp_implementation && python setup.py
google_
test --cpp_implementation && cd ..
-
cd python && python setup.py build --cpp_implementation && python setup.py test --cpp_implementation && cd ..
-
make distcheck -j2
notifications
:
email
:
false
python/README.md
View file @
9f42f5f4
...
...
@@ -50,7 +50,7 @@ Installation
4) Build and run the tests:
$ python setup.py build
$ python setup.py
google_
test
$ python setup.py test
To build, test, and use the C++ implementation, you must first compile
libprotobuf.so:
...
...
@@ -82,7 +82,7 @@ Installation
$ python setup.py build --cpp_implementation
Then run the tests like so:
$ python setup.py
google_
test --cpp_implementation
$ python setup.py test --cpp_implementation
If some tests fail, this library may not work correctly on your
system. Continue at your own risk.
...
...
python/google/protobuf/internal/_parameterized.py
View file @
9f42f5f4
...
...
@@ -152,8 +152,6 @@ import types
import
unittest
import
uuid
from
google.apputils
import
basetest
ADDR_RE
=
re
.
compile
(
r'\<([a-zA-Z0-9_\-\.]+) object at 0x[a-fA-F0-9]+\>'
)
_SEPARATOR
=
uuid
.
uuid1
()
.
hex
_FIRST_ARG
=
object
()
...
...
@@ -380,7 +378,7 @@ def _UpdateClassDictForParamTestCase(dct, id_suffix, name, iterator):
id_suffix
[
new_name
]
=
getattr
(
func
,
'__x_extra_id__'
,
''
)
class
ParameterizedTestCase
(
base
test
.
TestCase
):
class
ParameterizedTestCase
(
unit
test
.
TestCase
):
"""Base class for test cases using the Parameters decorator."""
__metaclass__
=
TestGeneratorMetaclass
...
...
python/google/protobuf/internal/descriptor_database_test.py
View file @
9f42f5f4
...
...
@@ -34,13 +34,14 @@
__author__
=
'matthewtoia@google.com (Matt Toia)'
from
google.apputils
import
basetest
import
unittest
from
google.protobuf
import
descriptor_pb2
from
google.protobuf.internal
import
factory_test2_pb2
from
google.protobuf
import
descriptor_database
class
DescriptorDatabaseTest
(
base
test
.
TestCase
):
class
DescriptorDatabaseTest
(
unit
test
.
TestCase
):
def
testAdd
(
self
):
db
=
descriptor_database
.
DescriptorDatabase
()
...
...
@@ -62,4 +63,4 @@ class DescriptorDatabaseTest(basetest.TestCase):
'google.protobuf.python.internal.MessageWithNestedEnumOnly.NestedEnum'
))
if
__name__
==
'__main__'
:
base
test
.
main
()
unit
test
.
main
()
python/google/protobuf/internal/descriptor_pool_test.py
View file @
9f42f5f4
...
...
@@ -37,7 +37,6 @@ __author__ = 'matthewtoia@google.com (Matt Toia)'
import
os
import
unittest
from
google.apputils
import
basetest
from
google.protobuf
import
unittest_pb2
from
google.protobuf
import
descriptor_pb2
from
google.protobuf.internal
import
api_implementation
...
...
@@ -51,7 +50,7 @@ from google.protobuf import descriptor_pool
from
google.protobuf
import
symbol_database
class
DescriptorPoolTest
(
base
test
.
TestCase
):
class
DescriptorPoolTest
(
unit
test
.
TestCase
):
def
setUp
(
self
):
self
.
pool
=
descriptor_pool
.
DescriptorPool
()
...
...
@@ -426,7 +425,7 @@ class ExtensionField(object):
test
.
assertEqual
(
self
.
extended_type
,
field_desc
.
containing_type
.
name
)
class
AddDescriptorTest
(
base
test
.
TestCase
):
class
AddDescriptorTest
(
unit
test
.
TestCase
):
def
_TestMessage
(
self
,
prefix
):
pool
=
descriptor_pool
.
DescriptorPool
()
...
...
@@ -588,4 +587,4 @@ TEST2_FILE = ProtoFile(
if
__name__
==
'__main__'
:
base
test
.
main
()
unit
test
.
main
()
python/google/protobuf/internal/descriptor_test.py
View file @
9f42f5f4
...
...
@@ -35,8 +35,8 @@
__author__
=
'robinson@google.com (Will Robinson)'
import
sys
import
unittest
from
google.apputils
import
basetest
from
google.protobuf
import
unittest_custom_options_pb2
from
google.protobuf
import
unittest_import_pb2
from
google.protobuf
import
unittest_pb2
...
...
@@ -52,7 +52,7 @@ name: 'TestEmptyMessage'
"""
class
DescriptorTest
(
base
test
.
TestCase
):
class
DescriptorTest
(
unit
test
.
TestCase
):
def
setUp
(
self
):
file_proto
=
descriptor_pb2
.
FileDescriptorProto
(
...
...
@@ -390,7 +390,7 @@ class DescriptorTest(basetest.TestCase):
self
.
assertEqual
(
self
.
my_file
.
name
,
'some/filename/some.proto'
)
self
.
assertEqual
(
self
.
my_file
.
package
,
'protobuf_unittest'
)
@
basetest.
unittest.skipIf
(
@unittest.skipIf
(
api_implementation
.
Type
()
!=
'cpp'
or
api_implementation
.
Version
()
!=
2
,
'Immutability of descriptors is only enforced in v2 implementation'
)
def
testImmutableCppDescriptor
(
self
):
...
...
@@ -403,7 +403,7 @@ class DescriptorTest(basetest.TestCase):
message_descriptor
.
fields
.
append
(
None
)
class
GeneratedDescriptorTest
(
base
test
.
TestCase
):
class
GeneratedDescriptorTest
(
unit
test
.
TestCase
):
"""Tests for the properties of descriptors in generated code."""
def
CheckMessageDescriptor
(
self
,
message_descriptor
):
...
...
@@ -493,7 +493,7 @@ class GeneratedDescriptorTest(basetest.TestCase):
self
.
assertEqual
(
'FOO'
,
next
(
values_iter
)
.
name
)
class
DescriptorCopyToProtoTest
(
base
test
.
TestCase
):
class
DescriptorCopyToProtoTest
(
unit
test
.
TestCase
):
"""Tests for CopyTo functions of Descriptor."""
def
_AssertProtoEqual
(
self
,
actual_proto
,
expected_class
,
expected_ascii
):
...
...
@@ -694,7 +694,7 @@ class DescriptorCopyToProtoTest(basetest.TestCase):
# TEST_SERVICE_ASCII)
class
MakeDescriptorTest
(
base
test
.
TestCase
):
class
MakeDescriptorTest
(
unit
test
.
TestCase
):
def
testMakeDescriptorWithNestedFields
(
self
):
file_descriptor_proto
=
descriptor_pb2
.
FileDescriptorProto
()
...
...
@@ -776,4 +776,4 @@ class MakeDescriptorTest(basetest.TestCase):
options
.
Extensions
[
unittest_custom_options_pb2
.
msgopt
]
.
i
)
if
__name__
==
'__main__'
:
base
test
.
main
()
unit
test
.
main
()
python/google/protobuf/internal/generator_test.py
View file @
9f42f5f4
...
...
@@ -41,7 +41,8 @@ further ensures that we can use Python protocol message objects as we expect.
__author__
=
'robinson@google.com (Will Robinson)'
from
google.apputils
import
basetest
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
...
...
@@ -55,7 +56,7 @@ from google.protobuf import symbol_database
MAX_EXTENSION
=
536870912
class
GeneratorTest
(
base
test
.
TestCase
):
class
GeneratorTest
(
unit
test
.
TestCase
):
def
testNestedMessageDescriptor
(
self
):
field_name
=
'optional_nested_message'
...
...
@@ -291,7 +292,7 @@ class GeneratorTest(basetest.TestCase):
self
.
assertIs
(
desc
.
oneofs
[
0
],
desc
.
oneofs_by_name
[
'oneof_field'
])
nested_names
=
set
([
'oneof_uint32'
,
'oneof_nested_message'
,
'oneof_string'
,
'oneof_bytes'
])
self
.
assert
SameElements
(
self
.
assert
ItemsEqual
(
nested_names
,
[
field
.
name
for
field
in
desc
.
oneofs
[
0
]
.
fields
])
for
field_name
,
field_desc
in
desc
.
fields_by_name
.
iteritems
():
...
...
@@ -301,7 +302,7 @@ class GeneratorTest(basetest.TestCase):
self
.
assertIsNone
(
field_desc
.
containing_oneof
)
class
SymbolDatabaseRegistrationTest
(
base
test
.
TestCase
):
class
SymbolDatabaseRegistrationTest
(
unit
test
.
TestCase
):
"""Checks that messages, enums and files are correctly registered."""
def
testGetSymbol
(
self
):
...
...
@@ -340,4 +341,4 @@ class SymbolDatabaseRegistrationTest(basetest.TestCase):
'google/protobuf/unittest.proto'
)
.
name
)
if
__name__
==
'__main__'
:
base
test
.
main
()
unit
test
.
main
()
python/google/protobuf/internal/message_factory_test.py
View file @
9f42f5f4
...
...
@@ -34,7 +34,8 @@
__author__
=
'matthewtoia@google.com (Matt Toia)'
from
google.apputils
import
basetest
import
unittest
from
google.protobuf
import
descriptor_pb2
from
google.protobuf.internal
import
factory_test1_pb2
from
google.protobuf.internal
import
factory_test2_pb2
...
...
@@ -43,7 +44,7 @@ from google.protobuf import descriptor_pool
from
google.protobuf
import
message_factory
class
MessageFactoryTest
(
base
test
.
TestCase
):
class
MessageFactoryTest
(
unit
test
.
TestCase
):
def
setUp
(
self
):
self
.
factory_test1_fd
=
descriptor_pb2
.
FileDescriptorProto
.
FromString
(
...
...
@@ -104,17 +105,18 @@ class MessageFactoryTest(basetest.TestCase):
for
_
in
range
(
2
):
messages
=
message_factory
.
GetMessages
([
self
.
factory_test2_fd
,
self
.
factory_test1_fd
])
self
.
assert
ContainsSubset
(
[
'google.protobuf.python.internal.Factory2Message'
,
self
.
assert
True
(
set
(
[
'google.protobuf.python.internal.Factory2Message'
,
'google.protobuf.python.internal.Factory1Message'
],
messages
.
keys
(
))
)
.
issubset
(
set
(
messages
.
keys
())
))
self
.
_ExerciseDynamicClass
(
messages
[
'google.protobuf.python.internal.Factory2Message'
])
self
.
assert
ContainsSubset
(
[
'google.protobuf.python.internal.Factory2Message.one_more_field'
,
self
.
assert
True
(
set
(
[
'google.protobuf.python.internal.Factory2Message.one_more_field'
,
'google.protobuf.python.internal.another_field'
],
(
messages
[
'google.protobuf.python.internal.Factory1Message'
]
.
_extensions_by_name
.
keys
()))
)
.
issubset
(
set
(
messages
[
'google.protobuf.python.internal.Factory1Message'
]
.
_extensions_by_name
.
keys
())))
factory_msg1
=
messages
[
'google.protobuf.python.internal.Factory1Message'
]
msg1
=
messages
[
'google.protobuf.python.internal.Factory1Message'
]()
ext1
=
factory_msg1
.
_extensions_by_name
[
...
...
@@ -128,4 +130,4 @@ class MessageFactoryTest(basetest.TestCase):
if
__name__
==
'__main__'
:
base
test
.
main
()
unit
test
.
main
()
python/google/protobuf/internal/message_test.py
View file @
9f42f5f4
...
...
@@ -50,7 +50,6 @@ import pickle
import
sys
import
unittest
from
google.apputils
import
basetest
from
google.protobuf.internal
import
_parameterized
from
google.protobuf
import
unittest_pb2
from
google.protobuf
import
unittest_proto3_arena_pb2
...
...
@@ -75,7 +74,7 @@ def IsNegInf(val):
@_parameterized.Parameters
(
(
unittest_pb2
),
(
unittest_proto3_arena_pb2
))
class
MessageTest
(
base
test
.
TestCase
):
class
MessageTest
(
unit
test
.
TestCase
):
def
testBadUtf8String
(
self
,
message_module
):
if
api_implementation
.
Type
()
!=
'python'
:
...
...
@@ -887,7 +886,7 @@ class MessageTest(basetest.TestCase):
# Class to test proto2-only features (required, extensions, etc.)
class
Proto2Test
(
base
test
.
TestCase
):
class
Proto2Test
(
unit
test
.
TestCase
):
def
testFieldPresence
(
self
):
message
=
unittest_pb2
.
TestAllTypes
()
...
...
@@ -1037,7 +1036,7 @@ class Proto2Test(basetest.TestCase):
# Class to test proto3-only features/behavior (updated field presence & enums)
class
Proto3Test
(
base
test
.
TestCase
):
class
Proto3Test
(
unit
test
.
TestCase
):
def
testFieldPresence
(
self
):
message
=
unittest_proto3_arena_pb2
.
TestAllTypes
()
...
...
@@ -1115,7 +1114,7 @@ class Proto3Test(basetest.TestCase):
self
.
assertEqual
(
7654321
,
m2
.
repeated_nested_enum
[
0
])
class
ValidTypeNamesTest
(
base
test
.
TestCase
):
class
ValidTypeNamesTest
(
unit
test
.
TestCase
):
def
assertImportFromName
(
self
,
msg
,
base_name
):
# Parse <type 'module.class_name'> to extra 'some.name' as a string.
...
...
@@ -1138,4 +1137,4 @@ class ValidTypeNamesTest(basetest.TestCase):
if
__name__
==
'__main__'
:
base
test
.
main
()
unit
test
.
main
()
python/google/protobuf/internal/proto_builder_test.py
View file @
9f42f5f4
...
...
@@ -32,7 +32,7 @@
"""Tests for google.protobuf.proto_builder."""
from
google.apputils
import
base
test
import
unit
test
from
google.protobuf
import
descriptor_pb2
from
google.protobuf
import
descriptor_pool
...
...
@@ -40,7 +40,7 @@ from google.protobuf import proto_builder
from
google.protobuf
import
text_format
class
ProtoBuilderTest
(
base
test
.
TestCase
):
class
ProtoBuilderTest
(
unit
test
.
TestCase
):
def
setUp
(
self
):
self
.
_fields
=
{
...
...
@@ -74,4 +74,4 @@ class ProtoBuilderTest(basetest.TestCase):
if
__name__
==
'__main__'
:
base
test
.
main
()
unit
test
.
main
()
python/google/protobuf/internal/reflection_test.py
View file @
9f42f5f4
...
...
@@ -39,8 +39,8 @@ import copy
import
gc
import
operator
import
struct
import
unittest
from
google.apputils
import
basetest
from
google.protobuf
import
unittest_import_pb2
from
google.protobuf
import
unittest_mset_pb2
from
google.protobuf
import
unittest_pb2
...
...
@@ -102,7 +102,7 @@ class _MiniDecoder(object):
return
self
.
_pos
==
len
(
self
.
_bytes
)
class
ReflectionTest
(
base
test
.
TestCase
):
class
ReflectionTest
(
unit
test
.
TestCase
):
def
assertListsEqual
(
self
,
values
,
others
):
self
.
assertEqual
(
len
(
values
),
len
(
others
))
...
...
@@ -1619,7 +1619,7 @@ class ReflectionTest(basetest.TestCase):
self
.
assertFalse
(
proto
.
IsInitialized
(
errors
))
self
.
assertEqual
(
errors
,
[
'a'
,
'b'
,
'c'
])
@
basetest.
unittest.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
):
...
...
@@ -1792,7 +1792,7 @@ class ReflectionTest(basetest.TestCase):
# Just check the default value.
self
.
assertEqual
(
57
,
msg
.
inner
.
value
)
@
basetest.
unittest.skipIf
(
@unittest.skipIf
(
api_implementation
.
Type
()
!=
'cpp'
or
api_implementation
.
Version
()
!=
2
,
'CPPv2-specific test'
)
def
testBadArguments
(
self
):
...
...
@@ -1808,7 +1808,7 @@ class ReflectionTest(basetest.TestCase):
# into separate TestCase classes.
class
TestAllTypesEqualityTest
(
base
test
.
TestCase
):
class
TestAllTypesEqualityTest
(
unit
test
.
TestCase
):
def
setUp
(
self
):
self
.
first_proto
=
unittest_pb2
.
TestAllTypes
()
...
...
@@ -1824,7 +1824,7 @@ class TestAllTypesEqualityTest(basetest.TestCase):
self
.
assertEqual
(
self
.
first_proto
,
self
.
second_proto
)
class
FullProtosEqualityTest
(
base
test
.
TestCase
):
class
FullProtosEqualityTest
(
unit
test
.
TestCase
):
"""Equality tests using completely-full protos as a starting point."""
...
...
@@ -1910,7 +1910,7 @@ class FullProtosEqualityTest(basetest.TestCase):
self
.
assertEqual
(
self
.
first_proto
,
self
.
second_proto
)
class
ExtensionEqualityTest
(
base
test
.
TestCase
):
class
ExtensionEqualityTest
(
unit
test
.
TestCase
):
def
testExtensionEquality
(
self
):
first_proto
=
unittest_pb2
.
TestAllExtensions
()
...
...
@@ -1943,7 +1943,7 @@ class ExtensionEqualityTest(basetest.TestCase):
self
.
assertEqual
(
first_proto
,
second_proto
)
class
MutualRecursionEqualityTest
(
base
test
.
TestCase
):
class
MutualRecursionEqualityTest
(
unit
test
.
TestCase
):
def
testEqualityWithMutualRecursion
(
self
):
first_proto
=
unittest_pb2
.
TestMutualRecursionA
()
...
...
@@ -1955,7 +1955,7 @@ class MutualRecursionEqualityTest(basetest.TestCase):
self
.
assertEqual
(
first_proto
,
second_proto
)
class
ByteSizeTest
(
base
test
.
TestCase
):
class
ByteSizeTest
(
unit
test
.
TestCase
):
def
setUp
(
self
):
self
.
proto
=
unittest_pb2
.
TestAllTypes
()
...
...
@@ -2251,7 +2251,7 @@ class ByteSizeTest(basetest.TestCase):
# * Handling of empty submessages (with and without "has"
# bits set).
class
SerializationTest
(
base
test
.
TestCase
):
class
SerializationTest
(
unit
test
.
TestCase
):
def
testSerializeEmtpyMessage
(
self
):
first_proto
=
unittest_pb2
.
TestAllTypes
()
...
...
@@ -2802,7 +2802,7 @@ class SerializationTest(basetest.TestCase):
self
.
assertEqual
(
3
,
proto
.
repeated_int32
[
2
])
class
OptionsTest
(
base
test
.
TestCase
):
class
OptionsTest
(
unit
test
.
TestCase
):
def
testMessageOptions
(
self
):
proto
=
unittest_mset_pb2
.
TestMessageSet
()
...
...
@@ -2829,9 +2829,9 @@ class OptionsTest(basetest.TestCase):
class
ClassAPITest
(
base
test
.
TestCase
):
class
ClassAPITest
(
unit
test
.
TestCase
):
@
basetest.
unittest.skipIf
(
@unittest.skipIf
(
api_implementation
.
Type
()
==
'cpp'
and
api_implementation
.
Version
()
==
2
,
'C++ implementation requires a call to MakeDescriptor()'
)
def
testMakeClassWithNestedDescriptor
(
self
):
...
...
@@ -2963,4 +2963,4 @@ class ClassAPITest(basetest.TestCase):
self
.
assertEqual
(
msg
.
bar
.
baz
.
deep
,
4
)
if
__name__
==
'__main__'
:
base
test
.
main
()
unit
test
.
main
()
python/google/protobuf/internal/service_reflection_test.py
View file @
9f42f5f4
...
...
@@ -34,13 +34,14 @@
__author__
=
'petar@google.com (Petar Petrov)'
from
google.apputils
import
basetest
import
unittest
from
google.protobuf
import
unittest_pb2
from
google.protobuf
import
service_reflection
from
google.protobuf
import
service
class
FooUnitTest
(
base
test
.
TestCase
):
class
FooUnitTest
(
unit
test
.
TestCase
):
def
testService
(
self
):
class
MockRpcChannel
(
service
.
RpcChannel
):
...
...
@@ -133,4 +134,4 @@ class FooUnitTest(basetest.TestCase):
if
__name__
==
'__main__'
:
base
test
.
main
()
unit
test
.
main
()
python/google/protobuf/internal/symbol_database_test.py
View file @
9f42f5f4
...
...
@@ -32,12 +32,13 @@
"""Tests for google.protobuf.symbol_database."""
from
google.apputils
import
basetest
import
unittest
from
google.protobuf
import
unittest_pb2
from
google.protobuf
import
symbol_database
class
SymbolDatabaseTest
(
base
test
.
TestCase
):
class
SymbolDatabaseTest
(
unit
test
.
TestCase
):
def
_Database
(
self
):
db
=
symbol_database
.
SymbolDatabase
()
...
...
@@ -117,4 +118,4 @@ class SymbolDatabaseTest(basetest.TestCase):
if
__name__
==
'__main__'
:
base
test
.
main
()
unit
test
.
main
()
python/google/protobuf/internal/text_encoding_test.py
View file @
9f42f5f4
...
...
@@ -32,7 +32,8 @@
"""Tests for google.protobuf.text_encoding."""
from
google.apputils
import
basetest
import
unittest
from
google.protobuf
import
text_encoding
TEST_VALUES
=
[
...
...
@@ -50,7 +51,7 @@ TEST_VALUES = [
b
"
\010\011\012\013\014\015
"
)]
class
TextEncodingTestCase
(
base
test
.
TestCase
):
class
TextEncodingTestCase
(
unit
test
.
TestCase
):
def
testCEscape
(
self
):
for
escaped
,
escaped_utf8
,
unescaped
in
TEST_VALUES
:
self
.
assertEquals
(
escaped
,
...
...
@@ -65,4 +66,4 @@ class TextEncodingTestCase(basetest.TestCase):
if
__name__
==
"__main__"
:
base
test
.
main
()
unit
test
.
main
()
python/google/protobuf/internal/text_format_test.py
View file @
9f42f5f4
...
...
@@ -35,8 +35,8 @@
__author__
=
'kenton@google.com (Kenton Varda)'
import
re
import
unittest
from
google.apputils
import
basetest
from
google.protobuf.internal
import
_parameterized
from
google.protobuf
import
unittest_mset_pb2
...
...
@@ -47,7 +47,7 @@ from google.protobuf.internal import test_util
from
google.protobuf
import
text_format
# Base class with some common functionality.
class
TextFormatBase
(
base
test
.
TestCase
):
class
TextFormatBase
(
unit
test
.
TestCase
):
def
ReadGolden
(
self
,
golden_filename
):
with
test_util
.
GoldenFile
(
golden_filename
)
as
f
:
...
...
@@ -312,12 +312,12 @@ class TextFormatTest(TextFormatBase):
def
testParseGroupNotClosed
(
self
,
message_module
):
message
=
message_module
.
TestAllTypes
()
text
=
'RepeatedGroup: <'
self
.
assertRaises
WithLiteralMatch
(
self
.
assertRaises
Regexp
(
text_format
.
ParseError
,
'1:16 : Expected ">".'
,
text_format
.
Parse
,
text
,
message
)
text
=
'RepeatedGroup: {'
self
.
assertRaises
WithLiteralMatch
(
self
.
assertRaises
Regexp
(
text_format
.
ParseError
,
'1:16 : Expected "}".'
,
text_format
.
Parse
,
text
,
message
)
...
...
@@ -354,7 +354,7 @@ class TextFormatTest(TextFormatBase):
def
testParseBadIntValue
(
self
,
message_module
):
message
=
message_module
.
TestAllTypes
()
text
=
'optional_int32: bork'
self
.
assertRaises
WithLiteralMatch
(
self
.
assertRaises
Regexp
(
text_format
.
ParseError
,
(
'1:17 : Couldn
\'
t parse integer: bork'
),
text_format
.
Parse
,
text
,
message
)
...
...
@@ -569,12 +569,12 @@ class Proto2Tests(TextFormatBase):
def
testParseBadExtension
(
self
):
message
=
unittest_pb2
.
TestAllExtensions
()
text
=
'[unknown_extension]: 8
\n
'
self
.
assertRaises
WithLiteralMatch
(
self
.
assertRaises
Regexp
(
text_format
.
ParseError
,
'1:2 : Extension "unknown_extension" not registered.'
,
text_format
.
Parse
,
text
,
message
)
message
=
unittest_pb2
.
TestAllTypes
()
self
.
assertRaises
WithLiteralMatch
(
self
.
assertRaises
Regexp
(
text_format
.
ParseError
,
(
'1:2 : Message type "protobuf_unittest.TestAllTypes" does not have '
'extensions.'
),
...
...
@@ -593,7 +593,7 @@ class Proto2Tests(TextFormatBase):
message
=
unittest_pb2
.
TestAllExtensions
()
text
=
(
'[protobuf_unittest.optional_int32_extension]: 42 '
'[protobuf_unittest.optional_int32_extension]: 67'
)
self
.
assertRaises
WithLiteralMatch
(
self
.
assertRaises
Regexp
(
text_format
.
ParseError
,
(
'1:96 : Message type "protobuf_unittest.TestAllExtensions" '
'should not have multiple '
...
...
@@ -604,7 +604,7 @@ class Proto2Tests(TextFormatBase):
message
=
unittest_pb2
.
TestAllTypes
()
text
=
(
'optional_nested_message { bb: 1 } '
'optional_nested_message { bb: 2 }'
)
self
.
assertRaises
WithLiteralMatch
(
self
.
assertRaises
Regexp
(
text_format
.
ParseError
,
(
'1:65 : Message type "protobuf_unittest.TestAllTypes.NestedMessage" '
'should not have multiple "bb" fields.'
),
...
...
@@ -614,14 +614,14 @@ class Proto2Tests(TextFormatBase):
message
=
unittest_pb2
.
TestAllTypes
()
text
=
(
'optional_int32: 42 '
'optional_int32: 67'
)
self
.
assertRaises
WithLiteralMatch
(
self
.
assertRaises
Regexp
(
text_format
.
ParseError
,
(
'1:36 : Message type "protobuf_unittest.TestAllTypes" should not '
'have multiple "optional_int32" fields.'
),
text_format
.
Parse
,
text
,
message
)
class
TokenizerTest
(
base
test
.
TestCase
):
class
TokenizerTest
(
unit
test
.
TestCase
):
def
testSimpleTokenCases
(
self
):
text
=
(
'identifier1:"string1"
\n
\n\n
'
...
...
@@ -766,4 +766,4 @@ class TokenizerTest(basetest.TestCase):
if
__name__
==
'__main__'
:
base
test
.
main
()
unit
test
.
main
()
python/google/protobuf/internal/unknown_fields_test.py
View file @
9f42f5f4
...
...
@@ -35,7 +35,8 @@
__author__
=
'bohdank@google.com (Bohdan Koval)'
from
google.apputils
import
basetest
import
unittest
from
google.protobuf
import
unittest_mset_pb2
from
google.protobuf
import
unittest_pb2
from
google.protobuf
import
unittest_proto3_arena_pb2
...
...
@@ -46,7 +47,7 @@ from google.protobuf.internal import test_util
from
google.protobuf.internal
import
type_checkers
class
UnknownFieldsTest
(
base
test
.
TestCase
):
class
UnknownFieldsTest
(
unit
test
.
TestCase
):
def
setUp
(
self
):
self
.
descriptor
=
unittest_pb2
.
TestAllTypes
.
DESCRIPTOR
...
...
@@ -104,7 +105,7 @@ class UnknownFieldsTest(basetest.TestCase):
# fields when checking equality.
#
# TODO(haberman): fix this.
@
basetest.
unittest.skipIf
(
@unittest.skipIf
(
api_implementation
.
Type
()
==
'cpp'
and
api_implementation
.
Version
()
==
2
,
'C++ implementation does not expose unknown fields to Python'
)
def
testEquals
(
self
):
...
...
@@ -117,10 +118,10 @@ class UnknownFieldsTest(basetest.TestCase):
self
.
assertNotEqual
(
self
.
empty_message
,
message
)
@
basetest.
unittest.skipIf
(
@unittest.skipIf
(
api_implementation
.
Type
()
==
'cpp'
and
api_implementation
.
Version
()
==
2
,
'C++ implementation does not expose unknown fields to Python'
)
class
UnknownFieldsAccessorsTest
(
base
test
.
TestCase
):
class
UnknownFieldsAccessorsTest
(
unit
test
.
TestCase
):
def
setUp
(
self
):
self
.
descriptor
=
unittest_pb2
.
TestAllTypes
.
DESCRIPTOR
...
...
@@ -205,10 +206,10 @@ class UnknownFieldsAccessorsTest(basetest.TestCase):
@
basetest.
unittest.skipIf
(
@unittest.skipIf
(
api_implementation
.
Type
()
==
'cpp'
and
api_implementation
.
Version
()
==
2
,
'C++ implementation does not expose unknown fields to Python'
)
class
UnknownEnumValuesTest
(
base
test
.
TestCase
):
class
UnknownEnumValuesTest
(
unit
test
.
TestCase
):
def
setUp
(
self
):
self
.
descriptor
=
missing_enum_values_pb2
.
TestEnumValues
.
DESCRIPTOR
...
...
@@ -261,4 +262,4 @@ class UnknownEnumValuesTest(basetest.TestCase):
if
__name__
==
'__main__'
:
base
test
.
main
()
unit
test
.
main
()
python/google/protobuf/internal/wire_format_test.py
View file @
9f42f5f4
...
...
@@ -34,12 +34,13 @@
__author__
=
'robinson@google.com (Will Robinson)'
from
google.apputils
import
basetest
import
unittest
from
google.protobuf
import
message
from
google.protobuf.internal
import
wire_format
class
WireFormatTest
(
base
test
.
TestCase
):
class
WireFormatTest
(
unit
test
.
TestCase
):
def
testPackTag
(
self
):
field_number
=
0xabc
...
...
@@ -250,4 +251,4 @@ class WireFormatTest(basetest.TestCase):
if
__name__
==
'__main__'
:
base
test
.
main
()
unit
test
.
main
()
python/setup.py
View file @
9f42f5f4
...
...
@@ -165,7 +165,7 @@ if __name__ == '__main__':
version
=
GetVersion
(),
packages
=
[
'google'
],
namespace_packages
=
[
'google'
],
google_test_dir
=
"google/protobuf/internal"
,
test_suite
=
'google.protobuf.internal'
,
# Must list modules explicitly so that we don't install tests.
py_modules
=
[
'google.protobuf.internal.api_implementation'
,
...
...
@@ -194,11 +194,6 @@ if __name__ == '__main__':
'google.protobuf.text_format'
],
cmdclass
=
{
'clean'
:
clean
,
'build_py'
:
build_py
},
install_requires
=
[
'setuptools'
],
# TODO: Restore dependency once a Python 3 compatible google-apputils
# is released.
setup_requires
=
([
'google-apputils'
]
if
sys
.
version_info
[
0
]
<
3
else
[]),
ext_modules
=
ext_module_list
,
url
=
'https://developers.google.com/protocol-buffers/'
,
maintainer
=
maintainer_email
,
...
...
src/google/protobuf/arena_nc_test.py
View file @
9f42f5f4
...
...
@@ -32,11 +32,12 @@
"""Negative compilation unit tests for arena API."""
import
unittest
from
google3.testing.pybase
import
fake_target_util
from
google.apputils
import
basetest
class
ArenaNcTest
(
base
test
.
TestCase
):
class
ArenaNcTest
(
unit
test
.
TestCase
):
def
testCompilerErrors
(
self
):
"""Runs a list of tests to verify compiler error messages."""
...
...
@@ -56,4 +57,4 @@ class ArenaNcTest(basetest.TestCase):
)
if
__name__
==
'__main__'
:
base
test
.
main
()
unit
test
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment