summaryrefslogtreecommitdiff
path: root/admin
diff options
context:
space:
mode:
authorVlastimil Zíma <vlastimil.zima@nic.cz>2017-11-24 15:07:29 +0100
committerVlastimil Zíma <vlastimil.zima@nic.cz>2017-11-29 08:38:30 +0100
commit8f0ff0d27771514d16a415b8ac76d18ea0809f38 (patch)
tree06b56cd9666f85aec459e9264e4c724f86c70f0d /admin
parentf58d7cee3e9f4bff9854dc10ffcd105fb3bc6619 (diff)
downloadopenid-8f0ff0d27771514d16a415b8ac76d18ea0809f38.tar.gz
Pepify and add flake8
Diffstat (limited to 'admin')
-rwxr-xr-xadmin/builddiscover.py2
-rw-r--r--admin/gettlds.py2
-rwxr-xr-xadmin/runtests39
3 files changed, 24 insertions, 19 deletions
diff --git a/admin/builddiscover.py b/admin/builddiscover.py
index 011ab88..ef4ede9 100755
--- a/admin/builddiscover.py
+++ b/admin/builddiscover.py
@@ -29,6 +29,7 @@ manifest_header = """\
"""
+
def buildDiscover(base_url, out_dir):
"""Convert all files in a directory to apache mod_asis files in
another directory."""
@@ -63,6 +64,7 @@ def buildDiscover(base_url, out_dir):
manifest_file.write(chunk)
manifest_file.close()
+
if __name__ == '__main__':
import sys
buildDiscover(*sys.argv[1:])
diff --git a/admin/gettlds.py b/admin/gettlds.py
index f473224..b2a7c92 100644
--- a/admin/gettlds.py
+++ b/admin/gettlds.py
@@ -21,7 +21,7 @@ langs = {
'ruby': ("%w'",
"", " ", "",
"'"),
- }
+}
lang = sys.argv[1]
prefix, line_prefix, separator, line_suffix, suffix = langs[lang]
diff --git a/admin/runtests b/admin/runtests
index b2a3a79..db7a647 100755
--- a/admin/runtests
+++ b/admin/runtests
@@ -1,11 +1,14 @@
#!/usr/bin/env python
-import os.path, sys, warnings
+import os.path
+import sys
+import warnings
test_modules = [
'cryptutil',
'oidutil',
'dh',
- ]
+]
+
def fixpath():
try:
@@ -17,10 +20,11 @@ def fixpath():
print "putting %s in sys.path" % (parent,)
sys.path.insert(0, parent)
+
def otherTests():
failed = []
for module_name in test_modules:
- print 'Testing %s...' % (module_name,) ,
+ print 'Testing %s...' % (module_name,),
sys.stdout.flush()
module_name = 'openid.test.' + module_name
try:
@@ -31,17 +35,15 @@ def otherTests():
else:
try:
test_mod.test()
- except (SystemExit, KeyboardInterrupt):
- raise
- except:
+ except Exception:
sys.excepthook(*sys.exc_info())
failed.append(module_name)
else:
print 'Succeeded.'
-
return failed
+
def pyunitTests():
import unittest
pyunit_module_names = [
@@ -63,16 +65,16 @@ def pyunitTests():
'pape_draft5',
'rpverify',
'extension',
- ]
+ ]
pyunit_modules = [
__import__('openid.test.test_%s' % (name,), {}, {}, ['unused'])
for name in pyunit_module_names
- ]
+ ]
try:
from openid.test import test_examples
- except ImportError, e:
+ except ImportError as e:
if 'twill' in str(e):
warnings.warn("Could not import twill; skipping test_examples.")
else:
@@ -98,7 +100,7 @@ def pyunitTests():
'test_urinorm',
'test_yadis_discover',
'trustroot',
- ]
+ ]
loader = unittest.TestLoader()
s = unittest.TestSuite()
@@ -110,18 +112,17 @@ def pyunitTests():
m = __import__('openid.test.%s' % (name,), {}, {}, ['unused'])
try:
s.addTest(m.pyUnitTests())
- except AttributeError, ex:
+ except AttributeError as ex:
# because the AttributeError doesn't actually say which
# object it was.
print "Error loading tests from %s:" % (name,)
raise
- runner = unittest.TextTestRunner() # verbosity=2)
+ runner = unittest.TextTestRunner() # verbosity=2)
return runner.run(s)
-
def splitDir(d, count):
# in python2.4 and above, it's easier to spell this as
# d.rsplit(os.sep, count)
@@ -130,7 +131,6 @@ def splitDir(d, count):
return d
-
def _import_djopenid():
"""Import djopenid from examples/
@@ -153,7 +153,6 @@ def _import_djopenid():
sys.modules['djopenid'] = djopenid
-
def django_tests():
"""Runs tests from examples/djopenid.
@@ -167,11 +166,12 @@ def django_tests():
try:
import django.test.simple
- except ImportError, e:
+ except ImportError as e:
warnings.warn("django.test.simple not found; "
"django examples not tested.")
return 0
- import djopenid.server.models, djopenid.consumer.models
+ import djopenid.server.models
+ import djopenid.consumer.models
print "Testing Django examples:"
# These tests do get put in to a pyunit test suite, so we could run them
@@ -180,12 +180,14 @@ def django_tests():
return django.test.simple.run_tests([djopenid.server.models,
djopenid.consumer.models])
+
try:
bool
except NameError:
def bool(x):
return not not x
+
def main():
fixpath()
other_failed = otherTests()
@@ -200,5 +202,6 @@ def main():
(django_failures > 0))
return failed
+
if __name__ == '__main__':
sys.exit(main() and 1 or 0)