Skip to content

Commit d377ad0

Browse files
committed
Conversion to 4 spaces instead of tabs (ran "reindent -r"). This is the new style for Webware >= 1.1.
1 parent 2dc30b4 commit d377ad0

File tree

365 files changed

+41996
-42017
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

365 files changed

+41996
-42017
lines changed

.pylintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ max-module-lines=1500
296296

297297
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
298298
# tab).
299-
indent-string='\t'
299+
indent-string=' '
300300

301301

302302
# checks for:

AllTests.py

+130-130
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
on the command line which contain the test cases to be run.
77
88
Usage:
9-
python AllTests.py - Runs all the unittests
10-
python AllTests.py mypackage.MyFile - Runs the tests in 'mypackage/MyFile'
9+
python AllTests.py - Runs all the unittests
10+
python AllTests.py mypackage.MyFile - Runs the tests in 'mypackage/MyFile'
1111
1212
This module also has a test-wide configuration file which can be accessed by
1313
the function AllTests.config().
@@ -17,46 +17,46 @@
1717

1818
alltestnames = [
1919

20-
'WebUtils.Tests.TestHTMLTag.makeTestSuite',
20+
'WebUtils.Tests.TestHTMLTag.makeTestSuite',
2121

22-
'MiscUtils.Tests.TestCSVParser.CSVParserTests',
23-
'MiscUtils.Tests.TestNamedValueAccess.makeTestSuite',
24-
'MiscUtils.Tests.TestError.TestError',
25-
'MiscUtils.Tests.TestFuncs.TestFuncs',
26-
'MiscUtils.Tests.TestPickleCache.TestPickleCache',
27-
'MiscUtils.Tests.TestDataTable.TestDataTable',
28-
'MiscUtils.Tests.TestDateInterval.TestDateInterval',
29-
'MiscUtils.Tests.TestDictForArgs',
22+
'MiscUtils.Tests.TestCSVParser.CSVParserTests',
23+
'MiscUtils.Tests.TestNamedValueAccess.makeTestSuite',
24+
'MiscUtils.Tests.TestError.TestError',
25+
'MiscUtils.Tests.TestFuncs.TestFuncs',
26+
'MiscUtils.Tests.TestPickleCache.TestPickleCache',
27+
'MiscUtils.Tests.TestDataTable.TestDataTable',
28+
'MiscUtils.Tests.TestDateInterval.TestDateInterval',
29+
'MiscUtils.Tests.TestDictForArgs',
3030

31-
'WebKit.Tests.Basic.Test',
31+
'WebKit.Tests.Basic.Test',
3232

33-
'TaskKit.Tests.Test.makeTestSuite',
33+
'TaskKit.Tests.Test.makeTestSuite',
3434

35-
'PSP.Tests.PSPUtilsTest',
36-
'PSP.Tests.CompileTest',
35+
'PSP.Tests.PSPUtilsTest',
36+
'PSP.Tests.CompileTest',
3737

38-
'UserKit.Tests.ExampleTest',
39-
'UserKit.Tests.Test',
40-
'UserKit.Tests.UserManagerTest.makeTestSuite',
38+
'UserKit.Tests.ExampleTest',
39+
'UserKit.Tests.Test',
40+
'UserKit.Tests.UserManagerTest.makeTestSuite',
4141

4242
]
4343

4444
try:
45-
import unittest
45+
import unittest
4646
except ImportError: # Python < 2.1
47-
print "This module needs the Python unittest package (PyUnit)"
48-
print "available at http://pyunit.sourceforge.net"
49-
raise
47+
print "This module needs the Python unittest package (PyUnit)"
48+
print "available at http://pyunit.sourceforge.net"
49+
raise
5050
try:
51-
import logging
51+
import logging
5252
except ImportError: # Python < 2.3
53-
print "This module needs the Python logging system"
54-
print "available at http://www.red-dove.com/python_logging.html"
55-
raise
53+
print "This module needs the Python logging system"
54+
print "available at http://www.red-dove.com/python_logging.html"
55+
raise
5656
try:
57-
True, False
57+
True, False
5858
except NameError: # Python < 2.3
59-
True, False = 1, 0
59+
True, False = 1, 0
6060

6161
import sys, os, site
6262
from MiscUtils.Configurable import Configurable
@@ -66,128 +66,128 @@
6666

6767

6868
class _AllTestsConfig(Configurable):
69-
"""Configuration for tests.
69+
"""Configuration for tests.
7070
71-
E.g. which DBs to test, where to find DB utilities.
71+
E.g. which DBs to test, where to find DB utilities.
7272
73-
If individual tests need some configuration, put it here so it
74-
is easy for a new user to configure all the tests in one place.
73+
If individual tests need some configuration, put it here so it
74+
is easy for a new user to configure all the tests in one place.
7575
76-
"""
76+
"""
7777

78-
_defaultConfig = '''
79-
{ # Edit this file to activate more tests
78+
_defaultConfig = '''
79+
{ # Edit this file to activate more tests
8080
81-
# Turn on tests that use MySQL?
82-
'hasMysql': False,
81+
# Turn on tests that use MySQL?
82+
'hasMysql': False,
8383
84-
# If hasMysql is true, then these are used to connect:
85-
'mysqlTestInfo' : {
84+
# If hasMysql is true, then these are used to connect:
85+
'mysqlTestInfo' : {
8686
87-
# Where is MySQLdb lib located?
88-
# 'extraSysPath': ['/somewhere/MySQL-python-1.2.2/build/lib'],
89-
'extraSysPath': [],
87+
# Where is MySQLdb lib located?
88+
# 'extraSysPath': ['/somewhere/MySQL-python-1.2.2/build/lib'],
89+
'extraSysPath': [],
9090
91-
# Where is the MySQL client located (if not on the path)?
92-
# 'mysqlClient': '/usr/local/mysql/bin/mysql',
93-
# 'mysqlClient': 'c:/progra~1/mysql/mysqls~1.0/bin/mysql.exe',
94-
'mysqlClient': 'mysql',
91+
# Where is the MySQL client located (if not on the path)?
92+
# 'mysqlClient': '/usr/local/mysql/bin/mysql',
93+
# 'mysqlClient': 'c:/progra~1/mysql/mysqls~1.0/bin/mysql.exe',
94+
'mysqlClient': 'mysql',
9595
96-
# The name of the MySQL database to be used:
97-
'database': 'test', # Test case uses this,
98-
# but UserManagerTest.mkmodel/Settings.config also defines it.
96+
# The name of the MySQL database to be used:
97+
'database': 'test', # Test case uses this,
98+
# but UserManagerTest.mkmodel/Settings.config also defines it.
9999
100-
# This is passed to MySQLObjectStore():
101-
'DatabaseArgs': {
102-
'host': 'localhost',
103-
'port': 3306,
104-
'user': 'test', # should have all database privileges
105-
'passwd': '',
106-
},
107-
}
100+
# This is passed to MySQLObjectStore():
101+
'DatabaseArgs': {
102+
'host': 'localhost',
103+
'port': 3306,
104+
'user': 'test', # should have all database privileges
105+
'passwd': '',
106+
},
107+
}
108108
}
109109
'''
110110

111-
def configFilename(self):
112-
theFilename = os.path.join(os.path.dirname(__file__), 'AllTests.config')
113-
# The first time we are run, write a new configuration file.
114-
if not os.path.exists(theFilename):
115-
_log.info(' Creating new configuration file at "%s".'
116-
' You can customize it to run more tests.', theFilename)
117-
fp = open(theFilename, 'w')
118-
fp.write(_AllTestsConfig._defaultConfig)
119-
fp.close()
120-
return theFilename
121-
122-
def defaultConfig(self):
123-
default = eval(_AllTestsConfig._defaultConfig)
124-
return default
111+
def configFilename(self):
112+
theFilename = os.path.join(os.path.dirname(__file__), 'AllTests.config')
113+
# The first time we are run, write a new configuration file.
114+
if not os.path.exists(theFilename):
115+
_log.info(' Creating new configuration file at "%s".'
116+
' You can customize it to run more tests.', theFilename)
117+
fp = open(theFilename, 'w')
118+
fp.write(_AllTestsConfig._defaultConfig)
119+
fp.close()
120+
return theFilename
121+
122+
def defaultConfig(self):
123+
default = eval(_AllTestsConfig._defaultConfig)
124+
return default
125125

126126
def config():
127-
"""Return singleton of configuration file."""
128-
global _alltestConfig
129-
if _alltestConfig is None:
130-
_alltestConfig = _AllTestsConfig()
131-
return _alltestConfig
127+
"""Return singleton of configuration file."""
128+
global _alltestConfig
129+
if _alltestConfig is None:
130+
_alltestConfig = _AllTestsConfig()
131+
return _alltestConfig
132132

133133

134134
def checkAndAddPaths(listOfPaths):
135-
"""Check paths.
135+
"""Check paths.
136136
137-
Pass me a list of paths, and I will check that each one exists and
138-
add it to sys.paths. This is used by tests which need to use some
139-
required library such as database drivers.
137+
Pass me a list of paths, and I will check that each one exists and
138+
add it to sys.paths. This is used by tests which need to use some
139+
required library such as database drivers.
140140
141-
"""
142-
numBadPaths = 0
143-
for p in listOfPaths:
144-
p = os.path.abspath(p)
145-
if os.path.exists(p):
146-
site.addsitedir(p)
147-
else:
148-
numBadPaths += 1
149-
print 'WARNING: Trying to add paths to sys.path,'
150-
print ' but could not find "%s".' % p
151-
return numBadPaths # 0 = all were found
141+
"""
142+
numBadPaths = 0
143+
for p in listOfPaths:
144+
p = os.path.abspath(p)
145+
if os.path.exists(p):
146+
site.addsitedir(p)
147+
else:
148+
numBadPaths += 1
149+
print 'WARNING: Trying to add paths to sys.path,'
150+
print ' but could not find "%s".' % p
151+
return numBadPaths # 0 = all were found
152152

153153

154154
if __name__ == '__main__':
155-
# Configure logging
156-
logging.basicConfig() # default level is WARN
157-
print
158-
print
159-
# If no arguments are given, all of the test cases are run.
160-
if len(sys.argv) == 1:
161-
testnames = alltestnames
162-
verbosity = 2
163-
logging.getLogger().setLevel(logging.INFO)
164-
print 'Loading all Webware Tests...'
165-
else:
166-
testnames = sys.argv[1:]
167-
# Turn up verbosity and logging level
168-
verbosity = 3
169-
logging.getLogger().setLevel(logging.DEBUG)
170-
print 'Loading tests %s...' % testnames
171-
172-
tests = unittest.TestSuite()
173-
174-
# We could just use defaultTestLoader.loadTestsFromNames(),
175-
# but it doesn't give a good error message when it cannot load a test.
176-
# So we load all tests individually and raise appropriate exceptions.
177-
for t in testnames:
178-
try:
179-
tests.addTest(unittest.defaultTestLoader.loadTestsFromName(t))
180-
except Exception:
181-
print 'ERROR: Skipping tests from "%s".' % t
182-
try:
183-
__import__(t) # just try to import the test after loadig failed
184-
except ImportError:
185-
print 'Could not import the test module.'
186-
else:
187-
print 'Could not load the test suite.'
188-
from traceback import print_exc
189-
print_exc()
190-
191-
print
192-
print 'Running the tests...'
193-
unittest.TextTestRunner(verbosity=verbosity).run(tests)
155+
# Configure logging
156+
logging.basicConfig() # default level is WARN
157+
print
158+
print
159+
# If no arguments are given, all of the test cases are run.
160+
if len(sys.argv) == 1:
161+
testnames = alltestnames
162+
verbosity = 2
163+
logging.getLogger().setLevel(logging.INFO)
164+
print 'Loading all Webware Tests...'
165+
else:
166+
testnames = sys.argv[1:]
167+
# Turn up verbosity and logging level
168+
verbosity = 3
169+
logging.getLogger().setLevel(logging.DEBUG)
170+
print 'Loading tests %s...' % testnames
171+
172+
tests = unittest.TestSuite()
173+
174+
# We could just use defaultTestLoader.loadTestsFromNames(),
175+
# but it doesn't give a good error message when it cannot load a test.
176+
# So we load all tests individually and raise appropriate exceptions.
177+
for t in testnames:
178+
try:
179+
tests.addTest(unittest.defaultTestLoader.loadTestsFromName(t))
180+
except Exception:
181+
print 'ERROR: Skipping tests from "%s".' % t
182+
try:
183+
__import__(t) # just try to import the test after loadig failed
184+
except ImportError:
185+
print 'Could not import the test module.'
186+
else:
187+
print 'Could not load the test suite.'
188+
from traceback import print_exc
189+
print_exc()
190+
191+
print
192+
print 'Running the tests...'
193+
unittest.TextTestRunner(verbosity=verbosity).run(tests)

0 commit comments

Comments
 (0)