Remove dead helpers
This commit is contained in:
@@ -24,7 +24,8 @@ tests, docs, dependencies, and unsupported-platform CI were removed too.
|
||||
Also removed are generated per-schema `Reader`/`Builder` classes, synthetic
|
||||
`.Union` enums, `_has_by_field`/`_init_by_field`, allocation-size overrides,
|
||||
`from_bytes(builder=True)`, and `to_dict` ordering/base64 options. Incoming base64
|
||||
Data values in `from_dict` remain supported.
|
||||
Data values in `from_dict` remain supported. Unused schema reset/metadata helpers,
|
||||
schema equality, `_which_str`, and legacy exception arguments were removed too.
|
||||
`remove_import_hook()` remains a no-op for cereal/opendbc compatibility.
|
||||
|
||||
This is intentionally not a full upstream API replacement. The import and
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
# Adapted for use in pycapnp from pyzmq. See https://github.com/zeromq/pyzmq
|
||||
# for original project.
|
||||
|
||||
import fileinput # noqa
|
||||
import os
|
||||
import shutil
|
||||
import tarfile
|
||||
@@ -29,27 +28,8 @@ bundled_version = (1, 4, 0)
|
||||
libcapnp_name = "capnproto-c++-%i.%i.%i.tar.gz" % (bundled_version)
|
||||
libcapnp_url = "https://capnproto.org/" + libcapnp_name
|
||||
|
||||
HERE = os.path.dirname(__file__)
|
||||
ROOT = os.path.dirname(HERE)
|
||||
|
||||
|
||||
#
|
||||
# Utilities
|
||||
#
|
||||
|
||||
|
||||
def untgz(archive):
|
||||
"""Remove .tar.gz"""
|
||||
return archive.replace(".tar.gz", "")
|
||||
|
||||
|
||||
def localpath(*args):
|
||||
"""construct an absolute path from a list relative to the root pycapnp directory"""
|
||||
plist = [ROOT] + list(args)
|
||||
return os.path.abspath(pjoin(*plist))
|
||||
|
||||
|
||||
def fetch_archive(savedir, url, force=False):
|
||||
def fetch_archive(savedir, url):
|
||||
"""download an archive to a specific location"""
|
||||
req = urlopen(url)
|
||||
# Lookup filename
|
||||
@@ -57,7 +37,7 @@ def fetch_archive(savedir, url, force=False):
|
||||
if not fname:
|
||||
fname = os.path.basename(url)
|
||||
dest = pjoin(savedir, fname)
|
||||
if os.path.exists(dest) and not force:
|
||||
if os.path.exists(dest):
|
||||
print("already have %s" % fname)
|
||||
return dest
|
||||
print("fetching %s into %s" % (url, savedir))
|
||||
|
||||
@@ -7,7 +7,7 @@ from capnp.helpers.non_circular cimport (
|
||||
c_reraise_kj_exception as reraise_kj_exception,
|
||||
)
|
||||
from capnp.includes.schema_cpp cimport (
|
||||
Node, Data, Field as SchemaField, Enumerant as SchemaEnumerant, MessageBuilder, MessageReader, ReaderOptions,
|
||||
Node, Data, Field as SchemaField, Enumerant as SchemaEnumerant,
|
||||
)
|
||||
from capnp.includes.types cimport *
|
||||
|
||||
@@ -27,15 +27,12 @@ cdef extern from "capnp/common.h":
|
||||
cdef extern from "kj/string.h" namespace " ::kj":
|
||||
cdef cppclass StringPtr nogil:
|
||||
StringPtr()
|
||||
StringPtr(char *)
|
||||
StringPtr(char *, size_t)
|
||||
char* cStr()
|
||||
size_t size()
|
||||
char* begin()
|
||||
cdef cppclass String nogil:
|
||||
char* cStr()
|
||||
size_t size()
|
||||
char* begin()
|
||||
|
||||
cdef extern from "kj/exception.h" namespace " ::kj":
|
||||
cdef cppclass Exception nogil:
|
||||
@@ -51,13 +48,10 @@ cdef extern from "kj/string-tree.h" namespace " ::kj":
|
||||
|
||||
cdef extern from "kj/common.h" namespace " ::kj":
|
||||
cdef cppclass Maybe[T] nogil:
|
||||
T& orDefault(T&)
|
||||
pass
|
||||
cdef cppclass ArrayPtr[T] nogil:
|
||||
ArrayPtr()
|
||||
ArrayPtr(T *, size_t size)
|
||||
T* begin()
|
||||
size_t size()
|
||||
T& operator[](size_t index)
|
||||
|
||||
cdef extern from "capnp/schema.h" namespace " ::capnp":
|
||||
cdef cppclass SchemaType" ::capnp::Type" nogil:
|
||||
@@ -75,13 +69,10 @@ cdef extern from "capnp/schema.h" namespace " ::capnp":
|
||||
StructSchema asStruct() except +reraise_kj_exception
|
||||
EnumSchema asEnum() except +reraise_kj_exception
|
||||
ConstSchema asConst() except +reraise_kj_exception
|
||||
Schema getDependency(uint64_t id) except +reraise_kj_exception
|
||||
|
||||
cdef cppclass StructSchema(Schema) nogil:
|
||||
cppclass Field nogil:
|
||||
SchemaField.Reader getProto()
|
||||
StructSchema getContainingStruct()
|
||||
uint getIndex()
|
||||
SchemaType getType()
|
||||
|
||||
cppclass FieldList nogil:
|
||||
@@ -98,12 +89,10 @@ cdef extern from "capnp/schema.h" namespace " ::capnp":
|
||||
|
||||
Field getFieldByName(char * name) except +reraise_kj_exception
|
||||
|
||||
cbool operator == (StructSchema)
|
||||
|
||||
cdef cppclass EnumSchema nogil:
|
||||
cppclass Enumerant nogil:
|
||||
SchemaEnumerant.Reader getProto()
|
||||
EnumSchema getContainingEnum()
|
||||
uint16_t getOrdinal()
|
||||
|
||||
cppclass EnumerantList nogil:
|
||||
@@ -111,7 +100,6 @@ cdef extern from "capnp/schema.h" namespace " ::capnp":
|
||||
Enumerant operator[](uint index)
|
||||
|
||||
EnumerantList getEnumerants()
|
||||
Enumerant getEnumerantByName(char * name)
|
||||
Node.Reader getProto()
|
||||
|
||||
cdef cppclass ListSchema nogil:
|
||||
@@ -182,7 +170,6 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
uint size()
|
||||
void set(uint index, DynamicValueForward.Reader value) except +reraise_kj_exception
|
||||
DynamicValueForward.Builder init(uint index, uint size) except +reraise_kj_exception
|
||||
StructSchema getStructElementType'getSchema().getStructElementType'()
|
||||
DynamicList.Reader asReader() except +reraise_kj_exception
|
||||
|
||||
cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
@@ -191,19 +178,9 @@ cdef extern from "capnp/dynamic.h" namespace " ::capnp":
|
||||
Reader()
|
||||
Reader(Void value)
|
||||
Reader(cbool value)
|
||||
Reader(char value)
|
||||
Reader(short value)
|
||||
Reader(int value)
|
||||
Reader(long value)
|
||||
Reader(long long value)
|
||||
Reader(unsigned char value)
|
||||
Reader(unsigned short value)
|
||||
Reader(unsigned int value)
|
||||
Reader(unsigned long value)
|
||||
Reader(unsigned long long value)
|
||||
Reader(float value)
|
||||
Reader(double value)
|
||||
Reader(char* value)
|
||||
Reader(StringPtr value)
|
||||
Reader(DynamicList.Reader& value)
|
||||
Reader(DynamicEnum value)
|
||||
|
||||
@@ -31,10 +31,7 @@ cdef extern from "capnp/schema.capnp.h" namespace " ::capnp::schema":
|
||||
cppclass NestedNode nogil:
|
||||
cppclass Reader nogil:
|
||||
Text.Reader getName()
|
||||
uint64_t getId()
|
||||
cppclass Reader nogil:
|
||||
Text.Reader getDisplayName()
|
||||
uint64_t getScopeId()
|
||||
uint64_t getId()
|
||||
ListNestedNodeReader getNestedNodes()
|
||||
bint isStruct()
|
||||
|
||||
@@ -45,7 +45,6 @@ cdef class _DynamicStructReader:
|
||||
cpdef _get(self, field)
|
||||
cpdef _has(self, field)
|
||||
cpdef _DynamicEnumField _which(self)
|
||||
cpdef _which_str(self)
|
||||
cpdef _get_by_field(self, _StructSchemaField field)
|
||||
cpdef as_builder(self)
|
||||
|
||||
@@ -68,7 +67,6 @@ cdef class _DynamicStructBuilder:
|
||||
cpdef _get_by_field(self, _StructSchemaField field)
|
||||
cpdef _set_by_field(self, _StructSchemaField field, value)
|
||||
cpdef _DynamicEnumField _which(self)
|
||||
cpdef _which_str(self)
|
||||
cpdef as_reader(self)
|
||||
cpdef copy(self)
|
||||
|
||||
|
||||
@@ -34,8 +34,6 @@ _CAPNP_VERSION_MINOR = capnp.CAPNP_VERSION_MINOR
|
||||
_CAPNP_VERSION_MICRO = capnp.CAPNP_VERSION_MICRO
|
||||
_CAPNP_VERSION = capnp.CAPNP_VERSION
|
||||
|
||||
cdef char _EMPTY_DATA_VIEW_SENTINEL = 0
|
||||
|
||||
cdef extern from "<kj/string.h>" namespace " ::kj":
|
||||
String strStructReader" ::kj::str"(C_DynamicStruct.Reader)
|
||||
String strStructBuilder" ::kj::str"(DynamicStruct_Builder)
|
||||
@@ -99,15 +97,13 @@ class KjException(Exception):
|
||||
|
||||
Type = _make_enum("Type", **{x: x for x in _Type.reverse_mapping.values()})
|
||||
|
||||
def __init__(self, message=None, nature=None, durability=None, wrapper=None, type=None):
|
||||
def __init__(self, message=None, wrapper=None, type=None):
|
||||
if wrapper is not None:
|
||||
self.wrapper = wrapper
|
||||
self.message = str(wrapper)
|
||||
else:
|
||||
self.wrapper = None
|
||||
self.message = message
|
||||
self.nature = nature
|
||||
self.durability = durability
|
||||
self._type = type
|
||||
|
||||
@property
|
||||
@@ -172,17 +168,6 @@ cdef extern from "Python.h":
|
||||
cdef int PyObject_GetBuffer(object, Py_buffer *view, int flags)
|
||||
cdef void PyBuffer_Release(Py_buffer *view)
|
||||
|
||||
# Templated classes are weird in cython. I couldn't put it in a pxd header for some reason
|
||||
cdef extern from "capnp/list.h" namespace " ::capnp":
|
||||
cdef cppclass List[T]:
|
||||
cppclass Reader:
|
||||
T operator[](uint) except +reraise_kj_exception
|
||||
uint size()
|
||||
cppclass Builder:
|
||||
T operator[](uint) except +reraise_kj_exception
|
||||
uint size()
|
||||
|
||||
|
||||
cdef extern from "<capnp/pretty-print.h>" namespace " ::capnp":
|
||||
StringTree printStructReader" ::capnp::prettyPrint"(C_DynamicStruct.Reader) except +reraise_kj_exception
|
||||
StringTree printStructBuilder" ::capnp::prettyPrint"(DynamicStruct_Builder) except +reraise_kj_exception
|
||||
@@ -196,14 +181,6 @@ cdef class _NodeReader:
|
||||
self.thisptr = other
|
||||
return self
|
||||
|
||||
property displayName:
|
||||
def __get__(self):
|
||||
return <char*>self.thisptr.getDisplayName().cStr()
|
||||
|
||||
property scopeId:
|
||||
def __get__(self):
|
||||
return self.thisptr.getScopeId()
|
||||
|
||||
property id:
|
||||
def __get__(self):
|
||||
return self.thisptr.getId()
|
||||
@@ -228,12 +205,6 @@ cdef class _NodeReader:
|
||||
def __get__(self):
|
||||
return self.thisptr.isEnum()
|
||||
|
||||
property node:
|
||||
"""A property that returns the NodeReader as a DynamicStructReader."""
|
||||
def __get__(self):
|
||||
return _DynamicStructReader()._init(self.thisptr, self)
|
||||
|
||||
|
||||
cdef class _NestedNodeReader:
|
||||
cdef C_Node.NestedNode.Reader thisptr
|
||||
cdef init(self, C_Node.NestedNode.Reader other):
|
||||
@@ -243,9 +214,6 @@ cdef class _NestedNodeReader:
|
||||
property name:
|
||||
def __get__(self):
|
||||
return <char*>self.thisptr.getName().cStr()
|
||||
property id:
|
||||
def __get__(self):
|
||||
return self.thisptr.getId()
|
||||
|
||||
|
||||
cdef class _DynamicListReader:
|
||||
@@ -570,7 +538,6 @@ cdef _setDynamicField(_DynamicSetterClasses thisptr, field, value, parent):
|
||||
.format(field, str(value), str(type(value))))
|
||||
|
||||
|
||||
# TODO: Is this function used by anyone? Can it be removed?
|
||||
cdef _setDynamicFieldWithField(DynamicStruct_Builder thisptr, _StructSchemaField field, value, parent):
|
||||
cdef C_DynamicValue.Reader temp
|
||||
value_type = type(value)
|
||||
@@ -620,13 +587,6 @@ cdef _setDynamicFieldWithField(DynamicStruct_Builder thisptr, _StructSchemaField
|
||||
.format(field, str(value), str(type(value))))
|
||||
|
||||
|
||||
# TODO: Is this function used by anyone? Can it be removed?
|
||||
cdef _DynamicListBuilder temp_list_b
|
||||
cdef _DynamicListReader temp_list_r
|
||||
cdef _DynamicStructBuilder temp_msg_b
|
||||
cdef _DynamicStructReader temp_msg_r
|
||||
|
||||
|
||||
cdef _to_dict(msg, bint verbose):
|
||||
msg_type = type(msg)
|
||||
if msg_type is _DynamicListBuilder:
|
||||
@@ -821,14 +781,6 @@ cdef class _DynamicStructReader:
|
||||
cpdef _has(self, field):
|
||||
return self.thisptr.has(field)
|
||||
|
||||
cpdef _which_str(self):
|
||||
try:
|
||||
return <char *>helpers.fixMaybe(self.thisptr.which()).getProto().getName().cStr()
|
||||
except RuntimeError as e:
|
||||
if str(e) == "Member was null.":
|
||||
raise KjException("Attempted to call which on a non-union type")
|
||||
raise
|
||||
|
||||
cpdef _DynamicEnumField _which(self):
|
||||
"""Returns the enum corresponding to the union in this struct
|
||||
|
||||
@@ -1004,14 +956,6 @@ cdef class _DynamicStructBuilder:
|
||||
ptr = self.thisptr.init(field, size)
|
||||
return to_python_builder(ptr, self._parent)
|
||||
|
||||
cpdef _which_str(self):
|
||||
try:
|
||||
return <char *>helpers.fixMaybe(self.thisptr.which()).getProto().getName().cStr()
|
||||
except RuntimeError as e:
|
||||
if str(e) == "Member was null.":
|
||||
raise KjException("Attempted to call which on a non-union type")
|
||||
raise
|
||||
|
||||
cpdef _DynamicEnumField _which(self):
|
||||
"""Returns the enum corresponding to the union in this struct
|
||||
|
||||
@@ -1144,8 +1088,7 @@ cdef class _Schema:
|
||||
|
||||
cdef class _StructSchema(_Schema):
|
||||
cdef C_StructSchema thisptr_child
|
||||
cdef object __fieldnames, __union_fields, __non_union_fields, __fields, __getters
|
||||
cdef list __fields_list
|
||||
cdef object __fieldnames, __union_fields, __non_union_fields, __fields
|
||||
cdef _init_child(self, C_StructSchema other):
|
||||
self.thisptr_child = other
|
||||
self._init(other)
|
||||
@@ -1153,8 +1096,6 @@ cdef class _StructSchema(_Schema):
|
||||
self.__union_fields = None
|
||||
self.__non_union_fields = None
|
||||
self.__fields = None
|
||||
self.__fields_list = None
|
||||
self.__getters = None
|
||||
return self
|
||||
|
||||
cdef C_StructSchema _thisptr(self):
|
||||
@@ -1205,29 +1146,11 @@ cdef class _StructSchema(_Schema):
|
||||
}
|
||||
return self.__fields
|
||||
|
||||
property fields_list:
|
||||
"""All of the _StructSchemaField in this schema as a list"""
|
||||
def __get__(self):
|
||||
if self.__fields_list is not None:
|
||||
return self.__fields_list
|
||||
fieldlist = self._thisptr().getFields()
|
||||
nfields = fieldlist.size()
|
||||
self.__fields_list = [_StructSchemaField()._init(fieldlist[i], self) for i in xrange(nfields)]
|
||||
return self.__fields_list
|
||||
|
||||
property node:
|
||||
"""The raw schema node"""
|
||||
def __get__(self):
|
||||
return _DynamicStructReader()._init(self._thisptr().getProto(), self)
|
||||
|
||||
def __richcmp__(_StructSchema self, _StructSchema other, mode):
|
||||
if mode == 2:
|
||||
return self._thisptr() == other._thisptr()
|
||||
elif mode == 3:
|
||||
return not (self._thisptr() == other._thisptr())
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
def __repr__(self):
|
||||
return '<schema for %s>' % self.node.displayName
|
||||
|
||||
@@ -1330,18 +1253,18 @@ class _StructModuleWhich(_enum.Enum):
|
||||
|
||||
|
||||
class _StructModule(object):
|
||||
def __init__(self, schema, name):
|
||||
def __init__(self, schema):
|
||||
self.schema = schema
|
||||
|
||||
# Add enums for union fields
|
||||
for field, raw_field in zip(schema.node.struct.fields, schema.fields_list):
|
||||
for field, raw_field in zip(schema.node.struct.fields, schema.fields.values()):
|
||||
if field.which() == 'group':
|
||||
name = field.name[0].upper() + field.name[1:]
|
||||
raw_schema = raw_field.schema
|
||||
field_schema = raw_schema.node.struct
|
||||
|
||||
if field_schema.discriminantCount == 0:
|
||||
sub_module = _StructModule(raw_schema, name)
|
||||
sub_module = _StructModule(raw_schema)
|
||||
else:
|
||||
mapping = []
|
||||
for union_field in field_schema.fields:
|
||||
@@ -1409,7 +1332,7 @@ class _StructModule(object):
|
||||
|
||||
|
||||
class _EnumModule(object):
|
||||
def __init__(self, schema, name):
|
||||
def __init__(self, schema):
|
||||
self.schema = schema
|
||||
for name, val in schema.enumerants.items():
|
||||
setattr(self, name, val)
|
||||
@@ -1510,7 +1433,7 @@ cdef class SchemaParser:
|
||||
schema = nodeSchema.get_nested(node.name)
|
||||
proto = schema.get_proto()
|
||||
if proto.isStruct:
|
||||
local_module = _StructModule(schema.as_struct(), node.name)
|
||||
local_module = _StructModule(schema.as_struct())
|
||||
|
||||
module.__dict__[node.name] = local_module
|
||||
elif proto.isConst:
|
||||
@@ -1518,7 +1441,7 @@ cdef class SchemaParser:
|
||||
elif proto.isInterface:
|
||||
continue
|
||||
elif proto.isEnum:
|
||||
local_module = _EnumModule(schema.as_enum(), node.name)
|
||||
local_module = _EnumModule(schema.as_enum())
|
||||
|
||||
module.__dict__[node.name] = local_module
|
||||
|
||||
@@ -1856,14 +1779,6 @@ cdef class _FlatArrayMessageReader(_MessageReader):
|
||||
_global_schema_parser = None
|
||||
|
||||
|
||||
def cleanup_global_schema_parser():
|
||||
"""Unloads all of the schema from the current context"""
|
||||
global _global_schema_parser
|
||||
if _global_schema_parser:
|
||||
del _global_schema_parser
|
||||
_global_schema_parser = None
|
||||
|
||||
|
||||
def load(file_name, display_name=None, imports=[]):
|
||||
"""Load a Cap'n Proto schema from a file
|
||||
|
||||
|
||||
7
setup.py
7
setup.py
@@ -103,13 +103,6 @@ class build_libcapnp_ext(build_ext_c):
|
||||
self.force_system_libcapnp = None
|
||||
self.libcapnp_url = None
|
||||
|
||||
def finalize_options(self):
|
||||
# print('The custom option for install is ', self.custom_option)
|
||||
build_ext_c.finalize_options(self)
|
||||
|
||||
def build_extension(self, ext):
|
||||
build_ext_c.build_extension(self, ext)
|
||||
|
||||
def run(self): # noqa: C901
|
||||
if self.force_bundled_libcapnp:
|
||||
need_build = True
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import os
|
||||
import platform
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
@@ -59,10 +58,6 @@ def test_large_read_multiple_bytes(test_capnp):
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
platform.python_implementation() == "PyPy",
|
||||
reason="PyPy memoryview support is limited",
|
||||
)
|
||||
def test_large_read_mutltiple_bytes_memoryview(test_capnp):
|
||||
data = get_two_adjacent_messages(test_capnp)
|
||||
for m in test_capnp.Msg.read_multiple_bytes(memoryview(data)):
|
||||
|
||||
@@ -4,15 +4,9 @@ import pytest
|
||||
import capnp
|
||||
import os
|
||||
import math
|
||||
import sys
|
||||
|
||||
this_dir = os.path.dirname(__file__)
|
||||
|
||||
if sys.version_info[0] < 3:
|
||||
EXPECT_BYTES = True
|
||||
else:
|
||||
EXPECT_BYTES = False
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def addressbook():
|
||||
@@ -351,9 +345,6 @@ def check_all_types(reader):
|
||||
assert subReader.textField == "☃"
|
||||
# This assertion highlights the encoding we expect to see here, since
|
||||
# otherwise this appears a bit magical...
|
||||
if EXPECT_BYTES:
|
||||
assert len(subReader.textField) == 3
|
||||
else:
|
||||
assert len(subReader.textField) == 1
|
||||
|
||||
assert subReader.dataField == b"qux"
|
||||
|
||||
@@ -8,7 +8,6 @@ import test_regression
|
||||
import tempfile
|
||||
import pickle
|
||||
import mmap
|
||||
import sys
|
||||
|
||||
this_dir = os.path.dirname(__file__)
|
||||
|
||||
@@ -27,10 +26,6 @@ def test_roundtrip_bytes(all_types):
|
||||
test_regression.check_all_types(msg)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.version_info[0] < 3,
|
||||
reason="mmap doesn't implement the buffer interface under python 2.",
|
||||
)
|
||||
def test_roundtrip_bytes_mmap(all_types):
|
||||
msg = all_types.TestAllTypes.new_message()
|
||||
test_regression.init_all_types(msg)
|
||||
|
||||
@@ -2,7 +2,6 @@ import pytest
|
||||
import capnp
|
||||
import os
|
||||
import tempfile
|
||||
import sys
|
||||
|
||||
from capnp.lib.capnp import KjException
|
||||
|
||||
@@ -42,9 +41,6 @@ def test_which_builder(addressbook):
|
||||
with pytest.raises(KjException):
|
||||
addresses._which()
|
||||
|
||||
with pytest.raises(KjException):
|
||||
addresses._which_str()
|
||||
|
||||
with pytest.raises(KjException):
|
||||
addresses.which
|
||||
|
||||
@@ -78,9 +74,6 @@ def test_which_reader(addressbook):
|
||||
bob = people[1]
|
||||
assert bob.employment.which == "unemployed"
|
||||
|
||||
with pytest.raises(KjException):
|
||||
addresses._which_str()
|
||||
|
||||
with pytest.raises(KjException):
|
||||
addresses._which()
|
||||
|
||||
@@ -88,10 +81,6 @@ def test_which_reader(addressbook):
|
||||
addresses.which
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
capnp.version.LIBCAPNP_VERSION < 5000,
|
||||
reason="Using ints as enums requires v0.5.0+ of the C++ capnp library",
|
||||
)
|
||||
def test_enum(addressbook):
|
||||
addresses = addressbook.AddressBook.new_message()
|
||||
people = addresses.init("people", 2)
|
||||
@@ -150,14 +139,8 @@ def test_null_str(all_types):
|
||||
def test_unicode_str(all_types):
|
||||
msg = all_types.TestAllTypes.new_message()
|
||||
|
||||
if sys.version_info[0] == 2:
|
||||
msg.textField = "f\u00e6oo".encode("utf-8")
|
||||
|
||||
assert msg.textField.decode("utf-8") == "f\u00e6oo"
|
||||
else:
|
||||
msg.textField = "f\u00e6oo"
|
||||
|
||||
assert msg.textField == "f\u00e6oo"
|
||||
msg.textField = "fæoo"
|
||||
assert msg.textField == "fæoo"
|
||||
|
||||
|
||||
def test_new_message(all_types):
|
||||
|
||||
Reference in New Issue
Block a user