Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Port CPython 3.6.5 test cases #8

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Add hyperjson test cases
  • Loading branch information
wdv4758h committed Jun 3, 2018
commit 0dbd2dc0b24a080368c3285fb17928ab8d98298c
21 changes: 21 additions & 0 deletions tests/cpython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# import json with and without accelerations
cjson = support.import_fresh_module('json', fresh=['_json'])
pyjson = support.import_fresh_module('json', blocked=['_json'])
hyperjson = support.import_fresh_module('hyperjson')
# JSONDecodeError is cached inside the _json module
cjson.JSONDecodeError = cjson.decoder.JSONDecodeError = json.JSONDecodeError

Expand All @@ -26,6 +27,16 @@ class CTest(unittest.TestCase):
dumps = staticmethod(cjson.dumps)
JSONDecodeError = staticmethod(cjson.JSONDecodeError)

@unittest.skipUnless(hyperjson, 'requires hyperjson')
class RustTest(unittest.TestCase):
if hyperjson is not None:
json = hyperjson
loads = staticmethod(hyperjson.loads)
dumps = staticmethod(hyperjson.dumps)
# FIXME: WTF
JSONDecodeError = staticmethod(pyjson.JSONDecodeError)
# JSONDecodeError = staticmethod(hyperjson.JSONDecodeError)

# test PyTest and CTest checking if the functions come from the right module
class TestPyTest(PyTest):
def test_pyjson(self):
Expand All @@ -44,6 +55,16 @@ def test_cjson(self):
self.assertEqual(self.json.encoder.encode_basestring_ascii.__module__,
'_json')

class TestRustTest(RustTest):
def test_hyperjson(self):
# FIXME:
pass
# self.assertEqual(self.json.scanner.make_scanner.__module__, 'hyperjson')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No clue what these scanner things are. I guess we should document that incompatibility somewhere. 🤔

# self.assertEqual(self.json.decoder.scanstring.__module__, 'hyperjson')
# self.assertEqual(self.json.encoder.c_make_encoder.__module__, 'hyperjson')
# self.assertEqual(self.json.encoder.encode_basestring_ascii.__module__,
# 'hyperjson')


def load_tests(loader, _, pattern):
suite = unittest.TestSuite()
Expand Down