summaryrefslogtreecommitdiff
path: root/passlib/tests
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2011-12-28 17:26:04 -0500
committerEli Collins <elic@assurancetechnologies.com>2011-12-28 17:26:04 -0500
commitfec9d1c45fcd201eea26f5ce276825302f10dce0 (patch)
tree4381eb3b2321d4dd8ac0814b9fff046864cfdbed /passlib/tests
parent9d1ca56acb757a034d66eb0b97acf0ca06245146 (diff)
downloadpasslib-fec9d1c45fcd201eea26f5ce276825302f10dce0.tar.gz
removed Undef singleton, private _NOTSET singletons are cleaner.
Diffstat (limited to 'passlib/tests')
-rw-r--r--passlib/tests/test_ext_django.py13
-rw-r--r--passlib/tests/test_utils.py12
2 files changed, 8 insertions, 17 deletions
diff --git a/passlib/tests/test_ext_django.py b/passlib/tests/test_ext_django.py
index 801f03e..008e397 100644
--- a/passlib/tests/test_ext_django.py
+++ b/passlib/tests/test_ext_django.py
@@ -15,7 +15,6 @@ from passlib.ext.django import utils
from passlib.hash import sha256_crypt
from passlib.tests.utils import TestCase, unittest, ut_version, catch_warnings
import passlib.tests.test_drivers as td
-from passlib.utils import Undef
from passlib.utils.compat import iteritems, get_method_function, unicode
from passlib.registry import get_crypt_handler
#module
@@ -53,9 +52,11 @@ if has_django:
if not settings.configured:
settings.configure()
+_NOTSET = object()
+
def update_settings(**kwds):
for k,v in iteritems(kwds):
- if v is Undef:
+ if v is _NOTSET:
if hasattr(settings, k):
if has_django0:
delattr(settings._target, k)
@@ -147,7 +148,7 @@ class PatchTest(TestCase):
self.assertEquals(func.__module__, "django.contrib.auth.models")
self.assertFalse(hasattr(dam.User, "password_context"))
- def assert_patched(self, context=Undef):
+ def assert_patched(self, context=_NOTSET):
"helper to ensure django HAS been patched"
state = utils._django_patch_state
@@ -172,7 +173,7 @@ class PatchTest(TestCase):
#make sure context matches
obj = dam.User.password_context
self.assertIs(obj, state['context'])
- if context is not Undef:
+ if context is not _NOTSET:
self.assertIs(obj, context)
#make sure old methods were stored
@@ -434,8 +435,8 @@ class PluginTest(TestCase):
#ensure django settings are empty
update_settings(
- PASSLIB_CONTEXT=Undef,
- PASSLIB_GET_CATEGORY=Undef,
+ PASSLIB_CONTEXT=_NOTSET,
+ PASSLIB_GET_CATEGORY=_NOTSET,
)
#unload module so it's re-run
diff --git a/passlib/tests/test_utils.py b/passlib/tests/test_utils.py
index dfd5f39..340a5a2 100644
--- a/passlib/tests/test_utils.py
+++ b/passlib/tests/test_utils.py
@@ -13,7 +13,7 @@ import warnings
#module
from passlib.context import CryptContext
from passlib import utils
-from passlib.utils import h64, des, Undef, bytes, b, \
+from passlib.utils import h64, des, bytes, b, \
to_bytes, to_unicode, to_native_str, \
is_same_codec, is_ascii_safe, safe_os_crypt, md4 as md4_mod
from passlib.utils.compat import unicode, PY3
@@ -32,16 +32,6 @@ class MiscTest(TestCase):
#NOTE: could test xor_bytes(), but it's exercised well enough by pbkdf2 test
- def test_undef(self):
- "test Undef singleton"
- self.assertEqual(repr(Undef), "<Undef>")
- self.assertFalse(Undef==None,)
- self.assertFalse(Undef==Undef,)
- self.assertFalse(Undef==True,)
- self.assertTrue(Undef!=None,)
- self.assertTrue(Undef!=Undef,)
- self.assertTrue(Undef!=True,)
-
def test_getrandbytes(self):
"test getrandbytes()"
def f(*a,**k):