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
2621c8ae
Commit
2621c8ae
authored
Aug 15, 2015
by
Dan O'Reilly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get Python 2.6 working.
Signed-off-by:
Dan O'Reilly
<
oreilldf@gmail.com
>
parent
d06adbd4
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
104 additions
and
69 deletions
+104
-69
_parameterized.py
python/google/protobuf/internal/_parameterized.py
+4
-1
descriptor_database_test.py
python/google/protobuf/internal/descriptor_database_test.py
+4
-1
descriptor_pool_test.py
python/google/protobuf/internal/descriptor_pool_test.py
+4
-2
descriptor_test.py
python/google/protobuf/internal/descriptor_test.py
+7
-3
generator_test.py
python/google/protobuf/internal/generator_test.py
+5
-2
message_factory_test.py
python/google/protobuf/internal/message_factory_test.py
+4
-1
message_test.py
python/google/protobuf/internal/message_test.py
+12
-9
proto_builder_test.py
python/google/protobuf/internal/proto_builder_test.py
+10
-3
reflection_test.py
python/google/protobuf/internal/reflection_test.py
+4
-12
service_reflection_test.py
python/google/protobuf/internal/service_reflection_test.py
+4
-1
symbol_database_test.py
python/google/protobuf/internal/symbol_database_test.py
+4
-1
text_encoding_test.py
python/google/protobuf/internal/text_encoding_test.py
+4
-1
text_format_test.py
python/google/protobuf/internal/text_format_test.py
+19
-16
unknown_fields_test.py
python/google/protobuf/internal/unknown_fields_test.py
+4
-12
wire_format_test.py
python/google/protobuf/internal/wire_format_test.py
+4
-1
proto_builder.py
python/google/protobuf/proto_builder.py
+5
-2
setup.py
python/setup.py
+6
-1
No files found.
python/google/protobuf/internal/_parameterized.py
View file @
2621c8ae
...
...
@@ -149,7 +149,10 @@ import collections
import
functools
import
re
import
types
import
unittest
try
:
import
unittest2
as
unittest
except
ImportError
:
import
unittest
import
uuid
import
six
...
...
python/google/protobuf/internal/descriptor_database_test.py
View file @
2621c8ae
...
...
@@ -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
...
...
python/google/protobuf/internal/descriptor_pool_test.py
View file @
2621c8ae
...
...
@@ -35,9 +35,11 @@
__author__
=
'matthewtoia@google.com (Matt Toia)'
import
os
import
unittest
try
:
import
unittest2
as
unittest
except
ImportError
:
import
unittest
import
unittest
from
google.protobuf
import
unittest_pb2
from
google.protobuf
import
descriptor_pb2
from
google.protobuf.internal
import
api_implementation
...
...
python/google/protobuf/internal/descriptor_test.py
View file @
2621c8ae
...
...
@@ -36,7 +36,6 @@ __author__ = 'robinson@google.com (Will Robinson)'
import
sys
import
unittest
from
google.protobuf
import
unittest_custom_options_pb2
from
google.protobuf
import
unittest_import_pb2
from
google.protobuf
import
unittest_pb2
...
...
@@ -46,6 +45,11 @@ from google.protobuf import descriptor
from
google.protobuf
import
symbol_database
from
google.protobuf
import
text_format
try
:
import
unittest2
as
unittest
except
ImportError
:
import
unittest
TEST_EMPTY_MESSAGE_DESCRIPTOR_ASCII
=
"""
name: 'TestEmptyMessage'
...
...
@@ -455,7 +459,7 @@ class GeneratedDescriptorTest(unittest.TestCase):
# properties of an immutable abc.Mapping.
self
.
assertGreater
(
len
(
mapping
),
0
)
# Sized
self
.
assertEqual
(
len
(
mapping
),
len
(
list
(
mapping
)))
# Iterable
if
sys
.
version_info
.
major
>=
3
:
if
sys
.
version_info
>=
(
3
,)
:
key
,
item
=
next
(
iter
(
mapping
.
items
()))
else
:
key
,
item
=
mapping
.
items
()[
0
]
...
...
@@ -464,7 +468,7 @@ class GeneratedDescriptorTest(unittest.TestCase):
# keys(), iterkeys() &co
item
=
(
next
(
iter
(
mapping
.
keys
())),
next
(
iter
(
mapping
.
values
())))
self
.
assertEqual
(
item
,
next
(
iter
(
mapping
.
items
())))
if
sys
.
version_info
.
major
<
3
:
if
sys
.
version_info
<
(
3
,)
:
def
CheckItems
(
seq
,
iterator
):
self
.
assertEqual
(
next
(
iterator
),
seq
[
0
])
self
.
assertEqual
(
list
(
iterator
),
seq
[
1
:])
...
...
python/google/protobuf/internal/generator_test.py
View file @
2621c8ae
...
...
@@ -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
...
...
@@ -153,7 +156,7 @@ class GeneratorTest(unittest.TestCase):
# extension and for its value to be set to -789.
def
testNestedTypes
(
self
):
self
.
assertEqual
s
(
self
.
assertEqual
(
set
(
unittest_pb2
.
TestAllTypes
.
DESCRIPTOR
.
nested_types
),
set
([
unittest_pb2
.
TestAllTypes
.
NestedMessage
.
DESCRIPTOR
,
...
...
python/google/protobuf/internal/message_factory_test.py
View file @
2621c8ae
...
...
@@ -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
...
...
python/google/protobuf/internal/message_test.py
View file @
2621c8ae
...
...
@@ -54,7 +54,10 @@ import six
if
six
.
PY3
:
long
=
int
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
...
...
@@ -324,7 +327,7 @@ class MessageTest(unittest.TestCase):
def
testHighPrecisionFloatPrinting
(
self
,
message_module
):
message
=
message_module
.
TestAllTypes
()
message
.
optional_double
=
0.12345678912345678
if
sys
.
version_info
.
major
>=
3
:
if
sys
.
version_info
>=
(
3
,)
:
self
.
assertEqual
(
str
(
message
),
'optional_double: 0.12345678912345678
\n
'
)
else
:
self
.
assertEqual
(
str
(
message
),
'optional_double: 0.123456789123
\n
'
)
...
...
@@ -443,7 +446,7 @@ class MessageTest(unittest.TestCase):
message
.
repeated_nested_message
.
sort
(
key
=
get_bb
,
reverse
=
True
)
self
.
assertEqual
([
k
.
bb
for
k
in
message
.
repeated_nested_message
],
[
6
,
5
,
4
,
3
,
2
,
1
])
if
sys
.
version_info
.
major
>=
3
:
return
# No cmp sorting in PY3.
if
sys
.
version_info
>=
(
3
,)
:
return
# No cmp sorting in PY3.
message
.
repeated_nested_message
.
sort
(
sort_function
=
cmp_bb
)
self
.
assertEqual
([
k
.
bb
for
k
in
message
.
repeated_nested_message
],
[
1
,
2
,
3
,
4
,
5
,
6
])
...
...
@@ -462,7 +465,7 @@ class MessageTest(unittest.TestCase):
self
.
assertEqual
(
list
(
message
.
repeated_int32
),
[
-
1
,
-
2
,
-
3
])
message
.
repeated_int32
.
sort
(
key
=
abs
,
reverse
=
True
)
self
.
assertEqual
(
list
(
message
.
repeated_int32
),
[
-
3
,
-
2
,
-
1
])
if
sys
.
version_info
.
major
<
3
:
# No cmp sorting in PY3.
if
sys
.
version_info
<
(
3
,)
:
# No cmp sorting in PY3.
abs_cmp
=
lambda
a
,
b
:
cmp
(
abs
(
a
),
abs
(
b
))
message
.
repeated_int32
.
sort
(
sort_function
=
abs_cmp
)
self
.
assertEqual
(
list
(
message
.
repeated_int32
),
[
-
1
,
-
2
,
-
3
])
...
...
@@ -476,7 +479,7 @@ class MessageTest(unittest.TestCase):
self
.
assertEqual
(
list
(
message
.
repeated_string
),
[
'c'
,
'bb'
,
'aaa'
])
message
.
repeated_string
.
sort
(
key
=
len
,
reverse
=
True
)
self
.
assertEqual
(
list
(
message
.
repeated_string
),
[
'aaa'
,
'bb'
,
'c'
])
if
sys
.
version_info
.
major
<
3
:
# No cmp sorting in PY3.
if
sys
.
version_info
<
(
3
,)
:
# No cmp sorting in PY3.
len_cmp
=
lambda
a
,
b
:
cmp
(
len
(
a
),
len
(
b
))
message
.
repeated_string
.
sort
(
sort_function
=
len_cmp
)
self
.
assertEqual
(
list
(
message
.
repeated_string
),
[
'c'
,
'bb'
,
'aaa'
])
...
...
@@ -499,7 +502,7 @@ class MessageTest(unittest.TestCase):
m2
.
repeated_nested_message
.
add
()
.
bb
=
2
m2
.
repeated_nested_message
.
add
()
.
bb
=
3
if
sys
.
version_info
.
major
>=
3
:
return
# No cmp() in PY3.
if
sys
.
version_info
>=
(
3
,)
:
return
# No cmp() in PY3.
# These comparisons should not raise errors.
_
=
m1
<
m2
...
...
@@ -1248,14 +1251,14 @@ class Proto3Test(unittest.TestCase):
msg
=
map_unittest_pb2
.
TestMap
()
self
.
assertIsNone
(
msg
.
map_int32_int32
.
get
(
5
))
self
.
assertEqual
s
(
10
,
msg
.
map_int32_int32
.
get
(
5
,
10
))
self
.
assertEqual
(
10
,
msg
.
map_int32_int32
.
get
(
5
,
10
))
self
.
assertIsNone
(
msg
.
map_int32_int32
.
get
(
5
))
msg
.
map_int32_int32
[
5
]
=
15
self
.
assertEqual
s
(
15
,
msg
.
map_int32_int32
.
get
(
5
))
self
.
assertEqual
(
15
,
msg
.
map_int32_int32
.
get
(
5
))
self
.
assertIsNone
(
msg
.
map_int32_foreign_message
.
get
(
5
))
self
.
assertEqual
s
(
10
,
msg
.
map_int32_foreign_message
.
get
(
5
,
10
))
self
.
assertEqual
(
10
,
msg
.
map_int32_foreign_message
.
get
(
5
,
10
))
submsg
=
msg
.
map_int32_foreign_message
[
5
]
self
.
assertIs
(
submsg
,
msg
.
map_int32_foreign_message
.
get
(
5
))
...
...
python/google/protobuf/internal/proto_builder_test.py
View file @
2621c8ae
...
...
@@ -32,8 +32,15 @@
"""Tests for google.protobuf.proto_builder."""
import
collections
import
unittest
try
:
from
collections
import
OrderedDict
except
ImportError
:
from
ordereddict
import
OrderedDict
#PY26
try
:
import
unittest2
as
unittest
#PY26
except
ImportError
:
import
unittest
from
google.protobuf
import
descriptor_pb2
from
google.protobuf
import
descriptor_pool
...
...
@@ -44,7 +51,7 @@ from google.protobuf import text_format
class
ProtoBuilderTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
ordered_fields
=
collections
.
OrderedDict
([
self
.
ordered_fields
=
OrderedDict
([
(
'foo'
,
descriptor_pb2
.
FieldDescriptorProto
.
TYPE_INT64
),
(
'bar'
,
descriptor_pb2
.
FieldDescriptorProto
.
TYPE_STRING
),
])
...
...
python/google/protobuf/internal/reflection_test.py
View file @
2621c8ae
...
...
@@ -39,18 +39,10 @@ import copy
import
gc
import
operator
import
struct
import
unittest
try
:
from
unittest
import
skipIf
import
unittest2
as
unittest
except
ImportError
:
def
skipIf
(
predicate
,
message
):
def
decorator
(
wrapped
):
if
predicate
:
def
_noop
(
*
args
,
**
kw
):
pass
return
_noop
return
wrapped
return
decorator
import
unittest
import
six
...
...
@@ -1634,7 +1626,7 @@ class ReflectionTest(unittest.TestCase):
self
.
assertFalse
(
proto
.
IsInitialized
(
errors
))
self
.
assertEqual
(
errors
,
[
'a'
,
'b'
,
'c'
])
@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
):
...
...
@@ -2835,7 +2827,7 @@ class OptionsTest(unittest.TestCase):
class
ClassAPITest
(
unittest
.
TestCase
):
@skipIf
(
@
unittest.
skipIf
(
api_implementation
.
Type
()
==
'cpp'
and
api_implementation
.
Version
()
==
2
,
'C++ implementation requires a call to MakeDescriptor()'
)
def
testMakeClassWithNestedDescriptor
(
self
):
...
...
python/google/protobuf/internal/service_reflection_test.py
View file @
2621c8ae
...
...
@@ -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
...
...
python/google/protobuf/internal/symbol_database_test.py
View file @
2621c8ae
...
...
@@ -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
symbol_database
...
...
python/google/protobuf/internal/text_encoding_test.py
View file @
2621c8ae
...
...
@@ -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
=
[
...
...
python/google/protobuf/internal/text_format_test.py
View file @
2621c8ae
...
...
@@ -38,7 +38,10 @@ import re
import
six
import
unittest
try
:
import
unittest2
as
unittest
except
ImportError
:
import
unittest
from
google.protobuf.internal
import
_parameterized
from
google.protobuf
import
map_unittest_pb2
...
...
@@ -62,7 +65,7 @@ class TextFormatBase(unittest.TestCase):
self
.
assertMultiLineEqual
(
text
,
''
.
join
(
golden_lines
))
def
CompareToGoldenText
(
self
,
text
,
golden_text
):
self
.
assert
MultiLine
Equal
(
text
,
golden_text
)
self
.
assertEqual
(
text
,
golden_text
)
def
RemoveRedundantZeros
(
self
,
text
):
# Some platforms print 1e+5 as 1e+005. This is fine, but we need to remove
...
...
@@ -218,13 +221,13 @@ class TextFormatTest(TextFormatBase):
text_message
=
text_format
.
MessageToString
(
message
,
float_format
=
'.15g'
)
self
.
CompareToGoldenText
(
self
.
RemoveRedundantZeros
(
text_message
),
'payload {{
\n
{
}
\n
{}
\n
{}
\n
{
}
\n
}}
\n
'
.
format
(
*
formatted_fields
))
'payload {{
\n
{
0}
\n
{1}
\n
{2}
\n
{3
}
\n
}}
\n
'
.
format
(
*
formatted_fields
))
# as_one_line=True is a separate code branch where float_format is passed.
text_message
=
text_format
.
MessageToString
(
message
,
as_one_line
=
True
,
float_format
=
'.15g'
)
self
.
CompareToGoldenText
(
self
.
RemoveRedundantZeros
(
text_message
),
'payload {{ {
} {} {} {
} }}'
.
format
(
*
formatted_fields
))
'payload {{ {
0} {1} {2} {3
} }}'
.
format
(
*
formatted_fields
))
def
testMessageToString
(
self
,
message_module
):
message
=
message_module
.
ForeignMessage
()
...
...
@@ -297,7 +300,7 @@ class TextFormatTest(TextFormatBase):
def
testParseSingleWord
(
self
,
message_module
):
message
=
message_module
.
TestAllTypes
()
text
=
'foo'
s
elf
.
assertRaisesRegexp
(
s
ix
.
assertRaisesRegex
(
self
,
text_format
.
ParseError
,
(
r'1:1 : Message type "\w+.TestAllTypes" has no field named '
r'"foo".'
),
...
...
@@ -306,7 +309,7 @@ class TextFormatTest(TextFormatBase):
def
testParseUnknownField
(
self
,
message_module
):
message
=
message_module
.
TestAllTypes
()
text
=
'unknown_field: 8
\n
'
s
elf
.
assertRaisesRegexp
(
s
ix
.
assertRaisesRegex
(
self
,
text_format
.
ParseError
,
(
r'1:1 : Message type "\w+.TestAllTypes" has no field named '
r'"unknown_field".'
),
...
...
@@ -315,7 +318,7 @@ class TextFormatTest(TextFormatBase):
def
testParseBadEnumValue
(
self
,
message_module
):
message
=
message_module
.
TestAllTypes
()
text
=
'optional_nested_enum: BARR'
s
elf
.
assertRaisesRegexp
(
s
ix
.
assertRaisesRegex
(
self
,
text_format
.
ParseError
,
(
r'1:23 : Enum type "\w+.TestAllTypes.NestedEnum" '
r'has no value named BARR.'
),
...
...
@@ -323,7 +326,7 @@ class TextFormatTest(TextFormatBase):
message
=
message_module
.
TestAllTypes
()
text
=
'optional_nested_enum: 100'
s
elf
.
assertRaisesRegexp
(
s
ix
.
assertRaisesRegex
(
self
,
text_format
.
ParseError
,
(
r'1:23 : Enum type "\w+.TestAllTypes.NestedEnum" '
r'has no value with number 100.'
),
...
...
@@ -332,7 +335,7 @@ class TextFormatTest(TextFormatBase):
def
testParseBadIntValue
(
self
,
message_module
):
message
=
message_module
.
TestAllTypes
()
text
=
'optional_int32: bork'
s
elf
.
assertRaisesRegexp
(
s
ix
.
assertRaisesRegex
(
self
,
text_format
.
ParseError
,
(
'1:17 : Couldn
\'
t parse integer: bork'
),
text_format
.
Parse
,
text
,
message
)
...
...
@@ -596,12 +599,12 @@ class Proto2Tests(TextFormatBase):
def
testParseBadExtension
(
self
):
message
=
unittest_pb2
.
TestAllExtensions
()
text
=
'[unknown_extension]: 8
\n
'
s
elf
.
assertRaisesRegexp
(
s
ix
.
assertRaisesRegex
(
self
,
text_format
.
ParseError
,
'1:2 : Extension "unknown_extension" not registered.'
,
text_format
.
Parse
,
text
,
message
)
message
=
unittest_pb2
.
TestAllTypes
()
s
elf
.
assertRaisesRegexp
(
s
ix
.
assertRaisesRegex
(
self
,
text_format
.
ParseError
,
(
'1:2 : Message type "protobuf_unittest.TestAllTypes" does not have '
'extensions.'
),
...
...
@@ -620,7 +623,7 @@ class Proto2Tests(TextFormatBase):
message
=
unittest_pb2
.
TestAllExtensions
()
text
=
(
'[protobuf_unittest.optional_int32_extension]: 42 '
'[protobuf_unittest.optional_int32_extension]: 67'
)
s
elf
.
assertRaisesRegexp
(
s
ix
.
assertRaisesRegex
(
self
,
text_format
.
ParseError
,
(
'1:96 : Message type "protobuf_unittest.TestAllExtensions" '
'should not have multiple '
...
...
@@ -631,7 +634,7 @@ class Proto2Tests(TextFormatBase):
message
=
unittest_pb2
.
TestAllTypes
()
text
=
(
'optional_nested_message { bb: 1 } '
'optional_nested_message { bb: 2 }'
)
s
elf
.
assertRaisesRegexp
(
s
ix
.
assertRaisesRegex
(
self
,
text_format
.
ParseError
,
(
'1:65 : Message type "protobuf_unittest.TestAllTypes.NestedMessage" '
'should not have multiple "bb" fields.'
),
...
...
@@ -641,7 +644,7 @@ class Proto2Tests(TextFormatBase):
message
=
unittest_pb2
.
TestAllTypes
()
text
=
(
'optional_int32: 42 '
'optional_int32: 67'
)
s
elf
.
assertRaisesRegexp
(
s
ix
.
assertRaisesRegex
(
self
,
text_format
.
ParseError
,
(
'1:36 : Message type "protobuf_unittest.TestAllTypes" should not '
'have multiple "optional_int32" fields.'
),
...
...
@@ -650,11 +653,11 @@ class Proto2Tests(TextFormatBase):
def
testParseGroupNotClosed
(
self
):
message
=
unittest_pb2
.
TestAllTypes
()
text
=
'RepeatedGroup: <'
s
elf
.
assertRaisesRegexp
(
s
ix
.
assertRaisesRegex
(
self
,
text_format
.
ParseError
,
'1:16 : Expected ">".'
,
text_format
.
Parse
,
text
,
message
)
text
=
'RepeatedGroup: {'
s
elf
.
assertRaisesRegexp
(
s
ix
.
assertRaisesRegex
(
self
,
text_format
.
ParseError
,
'1:16 : Expected "}".'
,
text_format
.
Parse
,
text
,
message
)
...
...
python/google/protobuf/internal/unknown_fields_test.py
View file @
2621c8ae
...
...
@@ -35,18 +35,10 @@
__author__
=
'bohdank@google.com (Bohdan Koval)'
import
unittest
try
:
from
unittest
import
skipIf
import
unittest2
as
unittest
except
ImportError
:
def
skipIf
(
predicate
,
message
):
def
decorator
(
wrapped
):
if
predicate
:
def
_noop
(
*
args
,
**
kw
):
pass
return
_noop
return
wrapped
return
decorator
import
unittest
from
google.protobuf
import
unittest_mset_pb2
from
google.protobuf
import
unittest_pb2
...
...
@@ -129,7 +121,7 @@ class UnknownFieldsTest(unittest.TestCase):
self
.
assertNotEqual
(
self
.
empty_message
,
message
)
@skipIf
(
@
unittest.
skipIf
(
api_implementation
.
Type
()
==
'cpp'
and
api_implementation
.
Version
()
==
2
,
'C++ implementation does not expose unknown fields to Python'
)
class
UnknownFieldsAccessorsTest
(
unittest
.
TestCase
):
...
...
@@ -217,7 +209,7 @@ class UnknownFieldsAccessorsTest(unittest.TestCase):
@skipIf
(
@
unittest.
skipIf
(
api_implementation
.
Type
()
==
'cpp'
and
api_implementation
.
Version
()
==
2
,
'C++ implementation does not expose unknown fields to Python'
)
class
UnknownEnumValuesTest
(
unittest
.
TestCase
):
...
...
python/google/protobuf/internal/wire_format_test.py
View file @
2621c8ae
...
...
@@ -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
...
...
python/google/protobuf/proto_builder.py
View file @
2621c8ae
...
...
@@ -30,7 +30,10 @@
"""Dynamic Protobuf class creator."""
import
collections
try
:
from
collections
import
OrderedDict
except
ImportError
:
from
ordereddict
import
OrderedDict
#PY26
import
hashlib
import
os
...
...
@@ -80,7 +83,7 @@ def MakeSimpleProtoClass(fields, full_name, pool=None):
# an OrderedDict we keep the order, but otherwise we sort the field to ensure
# consistent ordering.
field_items
=
fields
.
items
()
if
not
isinstance
(
fields
,
collections
.
OrderedDict
):
if
not
isinstance
(
fields
,
OrderedDict
):
field_items
=
sorted
(
field_items
)
# Use a consistent file name that is unlikely to conflict with any imported
...
...
python/setup.py
View file @
2621c8ae
...
...
@@ -158,6 +158,11 @@ if __name__ == '__main__':
)
os
.
environ
[
'PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'
]
=
'cpp'
install_requires
=
[
'six'
,
'setuptools'
]
if
sys
.
version_info
<=
(
2
,
7
):
install_requires
.
append
(
'ordereddict'
)
install_requires
.
append
(
'unittest2'
)
setup
(
name
=
'protobuf'
,
version
=
GetVersion
(),
...
...
@@ -187,6 +192,6 @@ if __name__ == '__main__':
'clean'
:
clean
,
'build_py'
:
build_py
,
},
install_requires
=
[
'setuptools'
,
'six'
]
,
install_requires
=
install_requires
,
ext_modules
=
ext_module_list
,
)
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