]> granicus.if.org Git - cracklib/commitdiff
add support for passing a dictionary path to Python test
authorJan Dittberner <jan@dittberner.info>
Sat, 19 May 2012 22:52:45 +0000 (22:52 +0000)
committerJan Dittberner <jan@dittberner.info>
Sat, 19 May 2012 22:52:45 +0000 (22:52 +0000)
git-svn-id: file:///tmp/cracklib-svn/trunk@198 4175fe1e-86d5-4fdc-8e6a-506fab9d8533

cracklib/python/cracklib.py
cracklib/python/setup.py.in
cracklib/python/test_cracklib.py

index 3f9572abab1b70273a33be565fbfe117ac8c7c9d..aee9a0d19387023a309eccffd7d33ff960ce3708 100644 (file)
@@ -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)
index a68f3b990cc5f54e2faa91991dd002af141051c0..e421b79b0b6cd4a6c2792d86a8d3af2e60df4b0b 100644 (file)
@@ -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=[
index 980b9b4828fabee1391207cb6062d7d4cba89735..cd20c90df920d601abd6dfccdc50fda4e9402176 100644 (file)
@@ -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: