forked from pool/python-FormEncode
173 lines
5.5 KiB
Diff
173 lines
5.5 KiB
Diff
|
Index: FormEncode-1.3.1/formencode/tests/test_context.py
|
||
|
===================================================================
|
||
|
--- FormEncode-1.3.1.orig/formencode/tests/test_context.py 2020-07-10 13:21:48.125612252 +0200
|
||
|
+++ FormEncode-1.3.1/formencode/tests/test_context.py 2020-07-10 14:11:53.460309142 +0200
|
||
|
@@ -1,55 +1,55 @@
|
||
|
from __future__ import absolute_import
|
||
|
-from nose.tools import assert_raises
|
||
|
+import unittest
|
||
|
|
||
|
from formencode.context import Context, ContextRestoreError
|
||
|
|
||
|
c1 = Context(default=None)
|
||
|
c2 = Context()
|
||
|
|
||
|
+class TestContext(unittest.TestCase):
|
||
|
|
||
|
-def test_one():
|
||
|
- state = c1.set(foo=1)
|
||
|
- assert_is(c1, 'foo', 1)
|
||
|
- state.restore()
|
||
|
- assert_is(c1, 'foo', None)
|
||
|
- state = c1.set(foo=2)
|
||
|
- state2 = c2.set(foo='test')
|
||
|
- assert_is(c1, 'foo', 2)
|
||
|
- assert_is(c2, 'foo', 'test')
|
||
|
- change_state(c1, assert_is, c1, 'foo', 3, foo=3)
|
||
|
- assert_is(c1, 'foo', 2)
|
||
|
- state.restore()
|
||
|
- state2.restore()
|
||
|
-
|
||
|
-
|
||
|
-def change_state(context, func, *args, **change):
|
||
|
- state = context.set(**change)
|
||
|
- try:
|
||
|
- return func(*args)
|
||
|
- finally:
|
||
|
+ def change_state(self, context, func, *args, **change):
|
||
|
+ state = context.set(**change)
|
||
|
+ try:
|
||
|
+ return func(*args)
|
||
|
+ finally:
|
||
|
+ state.restore()
|
||
|
+
|
||
|
+ def assert_is(self, ob, attr, value):
|
||
|
+ assert getattr(ob, attr) == value
|
||
|
+
|
||
|
+
|
||
|
+ def test_fail(self):
|
||
|
+ c3 = Context()
|
||
|
+ res1 = c3.set(a=1)
|
||
|
+ res2 = c3.set(b=2)
|
||
|
+ with self.assertRaises(ContextRestoreError):
|
||
|
+ res1.restore()
|
||
|
+ assert c3.b == 2
|
||
|
+ assert c3.a == 1
|
||
|
+ res2.restore()
|
||
|
+ res1.restore()
|
||
|
+
|
||
|
+ def test_default(self):
|
||
|
+ con = Context()
|
||
|
+ res = con.set(a=2)
|
||
|
+ con.set_default(a=4, b=1)
|
||
|
+ assert con.b == 1
|
||
|
+ assert con.a == 2
|
||
|
+ res.restore()
|
||
|
+ assert con.a == 4
|
||
|
+
|
||
|
+ def test_one(self):
|
||
|
+ state = c1.set(foo=1)
|
||
|
+ self.assert_is(c1, 'foo', 1)
|
||
|
state.restore()
|
||
|
+ self.assert_is(c1, 'foo', None)
|
||
|
+ state = c1.set(foo=2)
|
||
|
+ state2 = c2.set(foo='test')
|
||
|
+ self.assert_is(c1, 'foo', 2)
|
||
|
+ self.assert_is(c2, 'foo', 'test')
|
||
|
+ self.change_state(c1, self.assert_is, c1, 'foo', 3, foo=3)
|
||
|
+ self.assert_is(c1, 'foo', 2)
|
||
|
+ state.restore()
|
||
|
+ state2.restore()
|
||
|
|
||
|
-
|
||
|
-def test_fail():
|
||
|
- c3 = Context()
|
||
|
- res1 = c3.set(a=1)
|
||
|
- res2 = c3.set(b=2)
|
||
|
- assert_raises(ContextRestoreError, res1.restore)
|
||
|
- assert c3.b == 2
|
||
|
- assert c3.a == 1
|
||
|
- res2.restore()
|
||
|
- res1.restore()
|
||
|
-
|
||
|
-
|
||
|
-def assert_is(ob, attr, value):
|
||
|
- assert getattr(ob, attr) == value
|
||
|
-
|
||
|
-
|
||
|
-def test_default():
|
||
|
- con = Context()
|
||
|
- res = con.set(a=2)
|
||
|
- con.set_default(a=4, b=1)
|
||
|
- assert con.b == 1
|
||
|
- assert con.a == 2
|
||
|
- res.restore()
|
||
|
- assert con.a == 4
|
||
|
Index: FormEncode-1.3.1/formencode/tests/test_validators.py
|
||
|
===================================================================
|
||
|
--- FormEncode-1.3.1.orig/formencode/tests/test_validators.py 2020-07-10 13:21:48.125612252 +0200
|
||
|
+++ FormEncode-1.3.1/formencode/tests/test_validators.py 2020-07-10 14:12:08.540402950 +0200
|
||
|
@@ -4,7 +4,6 @@ from __future__ import unicode_literals
|
||
|
|
||
|
import datetime
|
||
|
import unittest
|
||
|
-from nose.plugins.skip import SkipTest
|
||
|
|
||
|
from formencode import validators
|
||
|
from formencode.validators import Invalid
|
||
|
Index: FormEncode-1.3.1/FormEncode.egg-info/requires.txt
|
||
|
===================================================================
|
||
|
--- FormEncode-1.3.1.orig/FormEncode.egg-info/requires.txt 2016-08-09 04:22:09.000000000 +0200
|
||
|
+++ FormEncode-1.3.1/FormEncode.egg-info/requires.txt 2020-07-10 14:14:06.917139411 +0200
|
||
|
@@ -1,5 +1,4 @@
|
||
|
|
||
|
[testing]
|
||
|
-nose
|
||
|
pycountry
|
||
|
dnspython
|
||
|
Index: FormEncode-1.3.1/formencode/tests/test_doctests.py
|
||
|
===================================================================
|
||
|
--- FormEncode-1.3.1.orig/formencode/tests/test_doctests.py 2020-07-10 13:21:48.125612252 +0200
|
||
|
+++ FormEncode-1.3.1/formencode/tests/test_doctests.py 2020-07-10 14:15:09.813530701 +0200
|
||
|
@@ -66,7 +66,7 @@ def doctest_module(document, verbose, ra
|
||
|
|
||
|
|
||
|
def set_func_description(fn, description):
|
||
|
- """Wrap function and set description attr for nosetests to display."""
|
||
|
+ """Wrap function and set description attr to display."""
|
||
|
def _wrapper(*a_test_args):
|
||
|
fn(*a_test_args)
|
||
|
_wrapper.description = description
|
||
|
@@ -75,7 +75,6 @@ def set_func_description(fn, description
|
||
|
|
||
|
def test_doctests():
|
||
|
"""Generate each doctest."""
|
||
|
- # TODO Can we resolve this from nose?
|
||
|
verbose = False
|
||
|
raise_error = True
|
||
|
for document in text_files + modules:
|
||
|
Index: FormEncode-1.3.1/setup.cfg
|
||
|
===================================================================
|
||
|
--- FormEncode-1.3.1.orig/setup.cfg 2016-08-09 04:22:10.000000000 +0200
|
||
|
+++ FormEncode-1.3.1/setup.cfg 2020-07-10 14:13:28.028897479 +0200
|
||
|
@@ -1,6 +1,3 @@
|
||
|
-[nosetests]
|
||
|
-detailed-errors = 1
|
||
|
-
|
||
|
[compile_catalog]
|
||
|
domain = FormEncode
|
||
|
directory = formencode/i18n
|
||
|
Index: FormEncode-1.3.1/setup.py
|
||
|
===================================================================
|
||
|
--- FormEncode-1.3.1.orig/setup.py 2020-07-10 13:21:48.129612276 +0200
|
||
|
+++ FormEncode-1.3.1/setup.py 2020-07-10 14:13:43.116991345 +0200
|
||
|
@@ -15,7 +15,7 @@ version = '1.3.1'
|
||
|
if not '2.6' <= sys.version < '3.0' and not '3.2' <= sys.version:
|
||
|
raise ImportError('Python version not supported')
|
||
|
|
||
|
-tests_require = ['nose', 'pycountry',
|
||
|
+tests_require = ['pycountry',
|
||
|
'dnspython' if sys.version < '3.0' else 'dnspython3']
|
||
|
|
||
|
doctests = ['docs/htmlfill.txt', 'docs/Validator.txt',
|