Skip to content

Commit

Permalink
Move to using builtin unittest for testing
Browse files Browse the repository at this point in the history
unittest2 appears not to be compatible with Python 3.10, so this
is a stepping stone towards getting testing working there.
  • Loading branch information
PeterJCLaw committed Mar 11, 2022
1 parent 69d0783 commit f6c3996
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
packages=['jsonobject'],
setup_requires=CYTHON_REQUIRES,
install_requires=['six'],
tests_require=['unittest2'],
ext_modules=extensions,
test_suite='test',
classifiers=(
Expand Down
2 changes: 1 addition & 1 deletion test/test_couchdbkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import unicode_literals
import json
import os
from unittest2 import TestCase
from unittest import TestCase
from .couchdbkit.application import Application
from io import open

Expand Down
4 changes: 2 additions & 2 deletions test/test_stringconversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import datetime
from jsonobject.exceptions import BadValueError
from jsonobject import JsonObject, ObjectProperty, DateTimeProperty
import unittest2
import unittest
from jsonobject.base import get_settings


class StringConversionsTest(unittest2.TestCase):
class StringConversionsTest(unittest.TestCase):

EXAMPLES = {
'decimal': '1.2',
Expand Down
20 changes: 10 additions & 10 deletions test/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import unicode_literals
import six
from copy import deepcopy
import unittest2
import unittest
from jsonobject import *
from jsonobject.exceptions import (
BadValueError,
Expand Down Expand Up @@ -68,7 +68,7 @@ class ObjectWithDictProperty(JsonObject):
mapping = DictProperty()


class JsonObjectTestCase(unittest2.TestCase):
class JsonObjectTestCase(unittest.TestCase):
def _danny_data(self):
return {
'first_name': 'Danny',
Expand Down Expand Up @@ -434,7 +434,7 @@ class Foo(JsonObject):
self.assertIsInstance(foo.bar, Bar)


class PropertyInsideContainerTest(unittest2.TestCase):
class PropertyInsideContainerTest(unittest.TestCase):

def test_default_is_required(self):
class Foo(JsonObject):
Expand Down Expand Up @@ -466,7 +466,7 @@ class Foo(JsonObject):
Foo(container=[None])


class LazyValidationTest(unittest2.TestCase):
class LazyValidationTest(unittest.TestCase):

def _validate_raises(self, foo):
with self.assertRaises(BadValueError):
Expand Down Expand Up @@ -577,7 +577,7 @@ class Foo(JsonObject):
self._validate_not_raises(foo)


class PropertyTestCase(unittest2.TestCase):
class PropertyTestCase(unittest.TestCase):
def test_date(self):
import datetime
p = DateProperty()
Expand Down Expand Up @@ -755,12 +755,12 @@ def test_attribute_error(self):
class Foo(JsonObject):
pass
foo = Foo()

with self.assertRaises(AttributeError):
foo.hello


class DynamicConversionTestCase(unittest2.TestCase):
class DynamicConversionTestCase(unittest.TestCase):
import datetime

class Foo(JsonObject):
Expand Down Expand Up @@ -843,7 +843,7 @@ class User(JsonObject):
tags = ListProperty(six.text_type)


class TestExactDateTime(unittest2.TestCase):
class TestExactDateTime(unittest.TestCase):
def test_exact(self):
class DateObj(JsonObject):
date = DateTimeProperty(exact=True)
Expand All @@ -862,7 +862,7 @@ class DateObj(JsonObject):
self.assertEqual(len(date_obj.to_json()['date']), 27)


class IntegerTest(unittest2.TestCase):
class IntegerTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
class Foo(JsonObject):
Expand All @@ -883,7 +883,7 @@ def test_set_zero(self):
self.assertEqual(foo.to_json()['my_int'], 0)


class TestReadmeExamples(unittest2.TestCase):
class TestReadmeExamples(unittest.TestCase):
def test(self):
import datetime
user1 = User(
Expand Down

0 comments on commit f6c3996

Please sign in to comment.