Skip to content

PR: Upgrade ujson dependency #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
#!/usr/bin/env python
from setuptools import find_packages, setup
import sys
import versioneer

README = open('README.rst', 'r').read()


install_requires = [
'future>=0.14.0; python_version<"3"',
'futures; python_version<"3.2"',
]

if sys.version_info[0] == 2:
install_requires.append('ujson<=2.0.3; platform_system!="Windows"')
else:
install_requires.append('ujson>=3.0.0')

setup(
name='python-jsonrpc-server',

Expand All @@ -31,11 +42,7 @@
# your project is installed. For an analysis of "install_requires" vs pip's
# requirements files see:
# https://packaging.python.org/en/latest/requirements.html
install_requires=[
'future>=0.14.0; python_version<"3"',
'futures; python_version<"3.2"',
'ujson<=1.35; platform_system!="Windows"',
],
install_requires=install_requires,

# List additional groups of dependencies here (e.g. development
# dependencies). You can install these using the following syntax,
Expand Down
14 changes: 13 additions & 1 deletion test/test_streams.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Copyright 2018 Palantir Technologies, Inc.
# pylint: disable=redefined-outer-name
from io import BytesIO
import datetime
import os
import sys
import mock
import pytest

Expand Down Expand Up @@ -95,11 +97,21 @@ def test_writer(wfile, writer):
)


class JsonDatetime(datetime.datetime):
"""Monkey path json datetime."""
def __json__(self):
if sys.version_info.major == 3:
dif = int(self.timestamp())
else:
dif = int((self - datetime.datetime(1970, 1, 1)).total_seconds())
return '{0}'.format(dif)


def test_writer_bad_message(wfile, writer):
# A datetime isn't serializable(or poorly serializable),
# ensure the write method doesn't throw, but the result could be empty
# or the correct datetime
import datetime
datetime.datetime = JsonDatetime
writer.write(datetime.datetime(
year=2019,
month=1,
Expand Down