From 6da094717ca99e527dc171975dabdb89037c5a2e Mon Sep 17 00:00:00 2001 From: Peter Law Date: Fri, 11 Mar 2022 18:18:14 +0000 Subject: [PATCH 1/2] Move to using builtin unittest for testing unittest2 appears not to be compatible with Python 3.10, so this is a stepping stone towards getting testing working there. --- setup.py | 1 - test/test_couchdbkit.py | 2 +- test/test_stringconversions.py | 4 ++-- test/tests.py | 20 ++++++++++---------- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/setup.py b/setup.py index a8a26b9..9a1d5bc 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,6 @@ packages=['jsonobject'], setup_requires=CYTHON_REQUIRES, install_requires=['six'], - tests_require=['unittest2'], ext_modules=extensions, test_suite='test', classifiers=( diff --git a/test/test_couchdbkit.py b/test/test_couchdbkit.py index 26eb622..eafd8ac 100644 --- a/test/test_couchdbkit.py +++ b/test/test_couchdbkit.py @@ -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 diff --git a/test/test_stringconversions.py b/test/test_stringconversions.py index 8da34be..5a74cb1 100644 --- a/test/test_stringconversions.py +++ b/test/test_stringconversions.py @@ -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', diff --git a/test/tests.py b/test/tests.py index 5a891b6..c3d855a 100644 --- a/test/tests.py +++ b/test/tests.py @@ -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, @@ -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', @@ -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): @@ -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): @@ -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() @@ -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): @@ -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) @@ -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): @@ -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( From eac15ea57b7378d87f3782481048b09a781b2c9e Mon Sep 17 00:00:00 2001 From: Peter Law Date: Fri, 11 Mar 2022 18:26:47 +0000 Subject: [PATCH 2/2] Support Python 3.10 This seems to already work, so this just enables testing and adds a classifier. --- .github/workflows/tests.yml | 2 +- setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b2bb934..22b407a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9"] + python-version: ["3.7", "3.8", "3.9", "3.10"] steps: - uses: actions/checkout@v2 diff --git a/setup.py b/setup.py index 9a1d5bc..9f9d8bb 100644 --- a/setup.py +++ b/setup.py @@ -61,6 +61,7 @@ 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'License :: OSI Approved :: BSD License', ), )