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
71edc31f
Commit
71edc31f
authored
Jan 13, 2015
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compatibility with Python2.6 unittest.
parent
47ee4d37
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
21 deletions
+35
-21
message_factory_test.py
python/google/protobuf/internal/message_factory_test.py
+2
-2
reflection_test.py
python/google/protobuf/internal/reflection_test.py
+20
-10
unknown_fields_test.py
python/google/protobuf/internal/unknown_fields_test.py
+13
-2
setup.py
python/setup.py
+0
-7
No files found.
python/google/protobuf/internal/message_factory_test.py
View file @
71edc31f
...
...
@@ -94,11 +94,11 @@ class MessageFactoryTest(unittest.TestCase):
factory
=
message_factory
.
MessageFactory
()
cls
=
factory
.
GetPrototype
(
pool
.
FindMessageTypeByName
(
'google.protobuf.python.internal.Factory2Message'
))
self
.
assert
IsNot
(
cls
,
factory_test2_pb2
.
Factory2Message
)
self
.
assert
False
(
cls
is
factory_test2_pb2
.
Factory2Message
)
self
.
_ExerciseDynamicClass
(
cls
)
cls2
=
factory
.
GetPrototype
(
pool
.
FindMessageTypeByName
(
'google.protobuf.python.internal.Factory2Message'
))
self
.
assert
Is
(
cls
,
cls2
)
self
.
assert
True
(
cls
is
cls2
)
def
testGetMessages
(
self
):
# performed twice because multiple calls with the same input must be allowed
...
...
python/google/protobuf/internal/reflection_test.py
View file @
71edc31f
...
...
@@ -40,6 +40,17 @@ import gc
import
operator
import
struct
import
unittest
try
:
from
unittest
import
skipIf
except
ImportError
:
def
skipIf
(
predicate
,
message
):
def
decorator
(
wrapped
):
if
predicate
:
def
_noop
(
*
args
,
**
kw
):
pass
return
_noop
return
wrapped
return
decorator
import
six
...
...
@@ -1623,7 +1634,7 @@ class ReflectionTest(unittest.TestCase):
self
.
assertFalse
(
proto
.
IsInitialized
(
errors
))
self
.
assertEqual
(
errors
,
[
'a'
,
'b'
,
'c'
])
@
unittest.
skipIf
(
@skipIf
(
api_implementation
.
Type
()
!=
'cpp'
or
api_implementation
.
Version
()
!=
2
,
'Errors are only available from the most recent C++ implementation.'
)
def
testFileDescriptorErrors
(
self
):
...
...
@@ -1644,18 +1655,17 @@ class ReflectionTest(unittest.TestCase):
file_descriptor_proto
.
name
=
another_file_name
m2
=
file_descriptor_proto
.
message_type
.
add
()
m2
.
name
=
'msg2'
with
self
.
assertRaises
(
TypeError
)
as
cm
:
try
:
descriptor
.
FileDescriptor
(
another_file_name
,
package_name
,
serialized_pb
=
file_descriptor_proto
.
SerializeToString
())
self
.
assertTrue
(
hasattr
(
cm
,
'exception'
),
'
%
s not raised'
%
getattr
(
cm
.
expected
,
'__name__'
,
cm
.
expected
))
self
.
assertIn
(
'test_file_descriptor_errors.proto'
,
str
(
cm
.
exception
))
# Error message will say something about this definition being a
# duplicate, though we don't check the message exactly to avoid a
# dependency on the C++ logging code.
self
.
assertIn
(
'test_file_descriptor_errors.msg1'
,
str
(
cm
.
exception
))
except
TypeError
as
e
:
message
=
str
(
e
)
else
:
self
.
fail
(
"Did not raise TypeError"
)
self
.
assertTrue
(
'test_file_descriptor_errors.proto'
in
message
)
def
testStringUTF8Encoding
(
self
):
proto
=
unittest_pb2
.
TestAllTypes
()
...
...
@@ -2824,7 +2834,7 @@ class OptionsTest(unittest.TestCase):
class
ClassAPITest
(
unittest
.
TestCase
):
@
unittest.
skipIf
(
@skipIf
(
api_implementation
.
Type
()
==
'cpp'
and
api_implementation
.
Version
()
==
2
,
'C++ implementation requires a call to MakeDescriptor()'
)
def
testMakeClassWithNestedDescriptor
(
self
):
...
...
python/google/protobuf/internal/unknown_fields_test.py
View file @
71edc31f
...
...
@@ -36,6 +36,17 @@
__author__
=
'bohdank@google.com (Bohdan Koval)'
import
unittest
try
:
from
unittest
import
skipIf
except
ImportError
:
def
skipIf
(
predicate
,
message
):
def
decorator
(
wrapped
):
if
predicate
:
def
_noop
(
*
args
,
**
kw
):
pass
return
_noop
return
wrapped
return
decorator
from
google.protobuf
import
unittest_mset_pb2
from
google.protobuf
import
unittest_pb2
...
...
@@ -46,7 +57,7 @@ from google.protobuf.internal import test_util
from
google.protobuf.internal
import
type_checkers
@
unittest.
skipIf
(
@skipIf
(
api_implementation
.
Type
()
==
'cpp'
and
api_implementation
.
Version
()
==
2
,
'C++ implementation does not expose unknown fields to Python'
)
class
UnknownFieldsTest
(
unittest
.
TestCase
):
...
...
@@ -180,7 +191,7 @@ class UnknownFieldsTest(unittest.TestCase):
self
.
assertNotEqual
(
self
.
empty_message
,
message
)
@
unittest.
skipIf
(
@skipIf
(
api_implementation
.
Type
()
==
'cpp'
and
api_implementation
.
Version
()
==
2
,
'C++ implementation does not expose unknown fields to Python'
)
class
UnknownEnumValuesTest
(
unittest
.
TestCase
):
...
...
python/setup.py
View file @
71edc31f
...
...
@@ -135,13 +135,6 @@ class build_py(_build_py):
pass
# _build_py is an old-style class, so super() doesn't work.
_build_py
.
run
(
self
)
# TODO(mrovner): Subclass to run 2to3 on some files only.
# Tracing what https://wiki.python.org/moin/PortingPythonToPy3k's "Approach 2"
# section on how to get 2to3 to run on source files during install under
# Python 3. This class seems like a good place to put logic that calls
# python3's distutils.util.run_2to3 on the subset of the files we have in our
# release that are subject to conversion.
# See code reference in previous code review.
if
__name__
==
'__main__'
:
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