Browse Source

Remove impossible error in serializer and test with a C module

tags/nilmdb-2.0.0
Jim Paris 2 years ago
parent
commit
322b0ec423
2 changed files with 11 additions and 7 deletions
  1. +4
    -7
      nilmdb/utils/serializer.py
  2. +7
    -0
      tests/test_serializer.py

+ 4
- 7
nilmdb/utils/serializer.py View File

@@ -68,13 +68,10 @@ def serializer_proxy(obj_or_type):
class SerializerObjectProxy(object):
def __init__(self, obj_or_type, *args, **kwargs):
self.__object = obj_or_type
try:
if type(obj_or_type) == type:
classname = obj_or_type.__name__
else:
classname = obj_or_type.__class__.__name__
except AttributeError: # pragma: no cover
classname = "???"
if type(obj_or_type) == type:
classname = obj_or_type.__name__
else:
classname = obj_or_type.__class__.__name__
self.__call_queue = queue.Queue()
self.__thread = SerializerThread(classname, self.__call_queue)
self.__thread.daemon = True


+ 7
- 0
tests/test_serializer.py View File

@@ -6,6 +6,7 @@ from nose.tools import *
from nose.tools import assert_raises
import threading
import time
import nilmdb.server

from testutil.helpers import *

@@ -120,3 +121,9 @@ class TestSerializer(Base):
# trigger exception in __del__, which should be ignored
foo._SerializerObjectProxy__call_queue = None
del foo

def test_rocket(self):
# Serializer works on a C module?
sp = nilmdb.utils.serializer_proxy
rkt = sp(nilmdb.server.rocket.Rocket("int32_8", None))
eq_(rkt.binary_size, 40)

Loading…
Cancel
Save