From f18c09e1cd0df9923eedf15e2cb49beb19d5561c Mon Sep 17 00:00:00 2001 From: twmht Date: Tue, 25 Apr 2017 19:33:42 +0800 Subject: [PATCH] use pytest --- rocksdb/merge_operators.py | 22 ++++++++++++++++++++++ setup.py | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 rocksdb/merge_operators.py diff --git a/rocksdb/merge_operators.py b/rocksdb/merge_operators.py new file mode 100644 index 0000000..2484e67 --- /dev/null +++ b/rocksdb/merge_operators.py @@ -0,0 +1,22 @@ +import struct as py_struct +from interfaces import AssociativeMergeOperator + +class UintAddOperator(AssociativeMergeOperator): + def merge(self, key, existing_value, value): + if existing_value: + s = py_struct.unpack('Q', existing_value)[0] + py_struct.unpack('Q', value)[0] + return (True, py_struct.pack('Q', s)) + return (True, value) + + def name(self): + return b'uint64add' + +class StringAppendOperator(AssociativeMergeOperator): + def merge(self, key, existing_value, value): + if existing_value: + s = existing_value + ',' + value + return (True, s) + return (True, value) + + def name(self): + return b'StringAppendOperator' diff --git a/setup.py b/setup.py index 34133d1..0b3f59c 100644 --- a/setup.py +++ b/setup.py @@ -43,6 +43,7 @@ setup( package_dir={'rocksdb': 'rocksdb'}, packages=find_packages('.'), ext_modules=cythonize([mod1]), - test_suite='rocksdb.tests', + setup_requires=['pytest-runner'], + tests_require=['pytest'], include_package_data=True )