Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
0dac54bc
Commit
0dac54bc
authored
Jul 27, 2004
by
Stefan H. Holek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a --config-file switch so we can run tests in instances.
parent
c12e8be3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
17 deletions
+51
-17
test.py
test.py
+51
-17
No files found.
test.py
View file @
0dac54bc
...
...
@@ -46,7 +46,11 @@ named .testinfo, it will not be searched for tests. Really.)
In Python < 2.3 the -q flag is added to the setup.py command
line.)
-c use pychecker
-c
Use pychecker
--config-file filename
Configure Zope by loading the specified configuration file (zope.conf).
-d
Instead of the normal test harness, run a debug version which
...
...
@@ -79,6 +83,10 @@ named .testinfo, it will not be searched for tests. Really.)
of the DEBUG_ flags defined bythe Python gc module. Multiple options
can be specified by using "-G OPTION1 -G OPTION2."
--import-testing
Import the Testing module to setup the test ZODB. Useful for running
tests that forgot to "import Testing".
--libdir test_root
Search for tests starting in the specified start directory
(useful for testing components being developed outside the main
...
...
@@ -349,23 +357,25 @@ class ImmediateTestRunner(unittest.TextTestRunner):
# setup list of directories to put on the path
class
PathInit
:
def
__init__
(
self
,
build
,
libdir
=
None
):
# Calculate which directories we're going to add to sys.path, and cd
# to the appropriate working directory
org_cwd
=
os
.
getcwd
()
# Calculate which directories we're going to add to sys.path.
self
.
libdir
=
"lib/python"
# Hack sys.path
self
.
cwd
=
os
.
getcwd
()
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
self
.
cwd
,
self
.
libdir
))
self
.
home
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
sys
.
argv
[
0
]))
# test.py lives in bin directory when installed ...
dir
,
file
=
os
.
path
.
split
(
self
.
home
)
if
file
==
'bin'
:
self
.
home
=
dir
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
self
.
home
,
self
.
libdir
))
self
.
cwd
=
os
.
path
.
realpath
(
os
.
getcwd
())
# Hack again for external products.
global
functional
kind
=
functional
and
"functional"
or
"unit"
if
libdir
:
extra
=
os
.
path
.
join
(
org_cwd
,
libdir
)
print
"Running %s tests from %s"
%
(
kind
,
extra
)
self
.
libdir
=
extra
sys
.
path
.
insert
(
0
,
extra
)
self
.
libdir
=
os
.
path
.
realpath
(
os
.
path
.
join
(
self
.
cwd
,
libdir
))
else
:
print
"Running %s tests from %s"
%
(
kind
,
self
.
cwd
)
self
.
libdir
=
os
.
path
.
realpath
(
os
.
path
.
join
(
self
.
cwd
,
self
.
libdir
))
if
self
.
libdir
not
in
sys
.
path
:
sys
.
path
.
insert
(
0
,
self
.
libdir
)
print
"Running %s tests from %s"
%
(
kind
,
self
.
libdir
)
# Make sure functional tests find ftesting.zcml
if
functional
:
config_file
=
'ftesting.zcml'
...
...
@@ -456,7 +466,10 @@ class TestFileFinder:
def
find_tests
(
rx
):
global
finder
finder
=
TestFileFinder
(
pathinit
.
libdir
)
walkdir
=
test_dir
or
pathinit
.
libdir
if
test_dir
:
walkdir
=
os
.
path
.
realpath
(
os
.
path
.
join
(
pathinit
.
cwd
,
test_dir
))
else
:
walkdir
=
pathinit
.
libdir
os
.
path
.
walk
(
walkdir
,
finder
.
visit
,
rx
)
return
finder
.
files
...
...
@@ -602,16 +615,28 @@ def remove_stale_bytecode(arg, dirname, names):
os
.
unlink
(
fullname
)
def
main
(
module_filter
,
test_filter
,
libdir
):
if
not
keepStaleBytecode
:
os
.
path
.
walk
(
os
.
curdir
,
remove_stale_bytecode
,
None
)
global
pathinit
global
config_file
configure_logging
()
# Initialize the path and cwd
pathinit
=
PathInit
(
build
,
libdir
)
if
not
keepStaleBytecode
:
os
.
path
.
walk
(
pathinit
.
home
,
remove_stale_bytecode
,
None
)
# Load configuration
if
config_file
:
config_file
=
os
.
path
.
realpath
(
config_file
)
print
"Parsing %s"
%
config_file
import
Zope
Zope
.
configure
(
config_file
)
# Import Testing module to setup the test ZODB
if
import_testing
:
import
Testing
files
=
find_tests
(
module_filter
)
files
.
sort
()
...
...
@@ -640,7 +665,7 @@ def configure_logging():
"""Initialize the logging module."""
import
logging.config
# Get the log.ini file from the current directory instead of possibly
# Get the log.ini file from the current directory instead of possibly
# buried in the build directory. XXX This isn't perfect because if
# log.ini specifies a log file, it'll be relative to the build directory.
# Hmm...
...
...
@@ -676,6 +701,8 @@ def process_args(argv=None):
global
keepStaleBytecode
global
functional
global
test_dir
global
config_file
global
import_testing
if
argv
is
None
:
argv
=
sys
.
argv
...
...
@@ -701,11 +728,14 @@ def process_args(argv=None):
keepStaleBytecode
=
0
functional
=
False
test_dir
=
None
config_file
=
None
import_testing
=
False
try
:
opts
,
args
=
getopt
.
getopt
(
argv
[
1
:],
"a:bcdDfg:G:hLmprtTuv"
,
[
"all"
,
"help"
,
"libdir="
,
"times="
,
"keepbytecode"
,
"dir="
])
"keepbytecode"
,
"dir="
,
"config-file="
,
"import-testing"
])
except
getopt
.
error
,
msg
:
print
msg
print
"Try `python %s -h' for more information."
%
argv
[
0
]
...
...
@@ -772,6 +802,10 @@ def process_args(argv=None):
timesfn
=
v
elif
k
==
'--dir'
:
test_dir
=
v
elif
k
==
'--config-file'
:
config_file
=
v
elif
k
==
'--import-testing'
:
import_testing
=
True
if
gcthresh
is
not
None
:
if
gcthresh
==
0
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment