summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Dittberner <jan@dittberner.info>2012-05-19 22:52:45 +0000
committerJan Dittberner <jan@dittberner.info>2012-05-19 22:52:45 +0000
commit39d4c73466e0b727c4582e15b861c936c02aa128 (patch)
treee1395c020fae72665c330cce6fe11f1e9104d90c
parent4c3cbd8861b1846c0660e3c7cf0a16dd89abeb5a (diff)
downloadcracklib-39d4c73466e0b727c4582e15b861c936c02aa128.tar.gz
add support for passing a dictionary path to Python test
git-svn-id: file:///tmp/cracklib-svn/trunk@198 4175fe1e-86d5-4fdc-8e6a-506fab9d8533
-rw-r--r--cracklib/python/cracklib.py4
-rw-r--r--cracklib/python/setup.py.in2
-rw-r--r--cracklib/python/test_cracklib.py19
3 files changed, 14 insertions, 11 deletions
diff --git a/cracklib/python/cracklib.py b/cracklib/python/cracklib.py
index 3f9572a..aee9a0d 100644
--- a/cracklib/python/cracklib.py
+++ b/cracklib/python/cracklib.py
@@ -218,11 +218,11 @@ def VeryFascistCheck(new, old = None, dictpath = None):
return new
-def test(verbosity=1, repeat=1):
+def test(verbosity=1, repeat=1, dictpath=None):
"""Test cracklib methods."""
import test_cracklib
import sys
- result = test_cracklib.run(verbosity=verbosity, repeat=repeat)
+ result = test_cracklib.run(verbosity=verbosity, repeat=repeat, use_dictpath=dictpath)
if result.wasSuccessful():
sys.exit(0)
sys.exit(1)
diff --git a/cracklib/python/setup.py.in b/cracklib/python/setup.py.in
index a68f3b9..e421b79 100644
--- a/cracklib/python/setup.py.in
+++ b/cracklib/python/setup.py.in
@@ -42,7 +42,7 @@ convenience functions.
author_email="jan@dittberner.info",
url="http://cracklib.sourceforge.net/",
license="GPLv2+",
- py_modules=['cracklib'],
+ py_modules=['cracklib', 'test_cracklib'],
ext_modules=extensions,
zip_safe=False,
classifiers=[
diff --git a/cracklib/python/test_cracklib.py b/cracklib/python/test_cracklib.py
index 980b9b4..cd20c90 100644
--- a/cracklib/python/test_cracklib.py
+++ b/cracklib/python/test_cracklib.py
@@ -11,23 +11,24 @@ import cracklib
__version__ = '2.8.19'
tests = []
+dictpath = None
class TestModuleFunctions(unittest.TestCase):
def test_VeryFascistCheck(self):
try:
- cracklib.VeryFascistCheck('test')
+ cracklib.VeryFascistCheck('test', dictpath=dictpath)
self.fail('expected ValueError')
except ValueError:
pass
try:
- cracklib.VeryFascistCheck('LhIRI6JXpKhUqBjT')
+ cracklib.VeryFascistCheck('LhIRI6JXpKhUqBjT', dictpath=dictpath)
except ValueError:
self.fail('password should be good enough')
def test_palindrome(self):
try:
- cracklib.VeryFascistCheck('ot23#xyx#32to')
+ cracklib.VeryFascistCheck('ot23#xyx#32to', dictpath=dictpath)
self.fail('expected ValueError')
except ValueError:
e = sys.exc_info()[1]
@@ -35,7 +36,7 @@ class TestModuleFunctions(unittest.TestCase):
def test_same(self):
try:
- cracklib.VeryFascistCheck('test', 'test')
+ cracklib.VeryFascistCheck('test', 'test', dictpath=dictpath)
self.fail('expected ValueError')
except ValueError:
e = sys.exc_info()[1]
@@ -43,7 +44,7 @@ class TestModuleFunctions(unittest.TestCase):
def test_case_change(self):
try:
- cracklib.VeryFascistCheck('test', 'TeSt')
+ cracklib.VeryFascistCheck('test', 'TeSt', dictpath=dictpath)
self.fail('expected ValueError')
except ValueError:
e = sys.exc_info()[1]
@@ -51,7 +52,7 @@ class TestModuleFunctions(unittest.TestCase):
def test_similar(self):
try:
- cracklib.VeryFascistCheck('test12', 'test34')
+ cracklib.VeryFascistCheck('test12', 'test34', dictpath=dictpath)
self.fail('expected ValueError')
except ValueError:
e = sys.exc_info()[1]
@@ -59,7 +60,7 @@ class TestModuleFunctions(unittest.TestCase):
def test_simple(self):
try:
- cracklib.VeryFascistCheck('t3sx24')
+ cracklib.VeryFascistCheck('t3sx24', dictpath=dictpath)
self.fail('expected ValueError')
except ValueError:
e = sys.exc_info()[1]
@@ -121,10 +122,12 @@ class TestModuleFunctions(unittest.TestCase):
tests.append(TestModuleFunctions)
-def run(verbosity=1, repeat=1):
+def run(verbosity=1, repeat=1, use_dictpath=None):
+ global dictpath
print(('cracklib is installed in: ' + os.path.dirname(__file__)))
print(('cracklib version: ' + __version__))
print((sys.version))
+ dictpath=use_dictpath
suite = unittest.TestSuite()
for cls in tests: