~launchpad-pqm/launchpad/devel

2048 by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh
1
#!/usr/bin/env python2.4
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
2
##############################################################################
3
#
4
# Copyright (c) 2004 Zope Corporation and Contributors.
5
# All Rights Reserved.
6
#
7
# This software is subject to the provisions of the Zope Public License,
8
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
9
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
10
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
11
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
12
# FOR A PARTICULAR PURPOSE.
13
#
14
##############################################################################
15
"""Test script
16
17
$Id: test.py 25177 2004-06-02 13:17:31Z jim $
18
"""
2976.10.61 by Stuart Bishop
Update warning filters
19
import sys, os, psycopg, time, logging, warnings, re
809 by Canonical.com Patch Queue Manager
Nuke some arch-tags
20
2083 by Canonical.com Patch Queue Manager
[r=jamesh] testrunner improvements (?)
21
os.setpgrp() # So test_on_merge.py can reap its children
22
23
# Make tests run in a timezone no launchpad developers live in.
24
# Our tests need to run in any timezone.
25
# (No longer actually required, as PQM does this)
26
os.environ['TZ'] = 'Asia/Calcutta'
27
time.tzset()
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
28
29
here = os.path.dirname(os.path.realpath(__file__))
1806 by Canonical.com Patch Queue Manager
Always use sys.path.insert instead of sys.path.append to give precedence for launchpad libs that are inside our tree. r=stub
30
sys.path.insert(0, os.path.join(here, 'lib'))
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
31
32
# Set PYTHONPATH environment variable for spawned processes
33
os.environ['PYTHONPATH'] = ':'.join(sys.path)
34
2097 by Canonical.com Patch Queue Manager
[trivial] more import fascist improvements
35
# Install the import fascist import hook and atexit handler.
36
import importfascist
37
importfascist.install_import_fascist()
1968 by Canonical.com Patch Queue Manager
DatabaseCodeImportFascist: warn about database imports in browser code after running tests. [r=SteveA]
38
2103 by Canonical.com Patch Queue Manager
[trivial] improved warning output for tests, and fixed a bunch of ambiguous use of select results warnings. some xxx comments left in person code. one untested codepath in hct backend.
39
# Install the warning handler hook and atexit handler.
40
import warninghandler
41
warninghandler.install_warning_handler()
42
2976.10.126 by Stuart Bishop
Ensure ZCML overrides are generated
43
# Ensure overrides are generated
44
from configs import generate_overrides
45
generate_overrides()
2103 by Canonical.com Patch Queue Manager
[trivial] improved warning output for tests, and fixed a bunch of ambiguous use of select results warnings. some xxx comments left in person code. one untested codepath in hct backend.
46
2083 by Canonical.com Patch Queue Manager
[r=jamesh] testrunner improvements (?)
47
# Tell canonical.config to use the test config section in launchpad.conf
1628 by Canonical.com Patch Queue Manager
Configuration, Librian and Librarian test harness work
48
from canonical.config import config
49
config.setDefaultSection('testrunner')
50
3498.5.2 by Bjorn Tillenius
clarify a comment.
51
# Remove this module's directory from path, so that zope.testbrowser
52
# can import pystone from test:
3498.4.1 by Bjorn Tillenius
patch test.py to remove '.' from the python path, to allow testbrowser import pystone from test.
53
sys.path[:] = [p for p in sys.path if os.path.abspath(p) != here]
54
55
1210 by Canonical.com Patch Queue Manager
Refactor and document test harnesses
56
# Turn on psycopg debugging wrapper
57
#import canonical.database.debug
58
#canonical.database.debug.install()
59
2770.1.30 by Guilherme Salgado
Clean up the http_proxy env var before running tests, as we don't want the requests we make to localhost to be proxied
60
# Unset the http_proxy environment variable, because we're going to make
61
# requests to localhost and we don't wand this to be proxied.
62
try:
63
    os.environ.pop('http_proxy')
64
except KeyError:
65
    pass
66
2976.10.30 by Stuart Bishop
filter some test suite warnings
67
# Silence spurious warnings. Note that this does not propagate to subprocesses
68
# so this is not always as easy as it seems. Warnings caused by our code that
69
# need to be silenced should have an accomponied Bug reference.
2976.10.19 by Stuart Bishop
Update test.py for Zope3.2
70
#
71
warnings.filterwarnings(
72
        'ignore', 'PyCrypto', RuntimeWarning, 'twisted[.]conch[.]ssh'
73
        )
74
warnings.filterwarnings(
2976.10.30 by Stuart Bishop
filter some test suite warnings
75
        'ignore', 'twisted.python.plugin', DeprecationWarning, 'buildbot'
76
        )
77
warnings.filterwarnings(
78
        'ignore', 'The concrete concept of a view has been deprecated.',
79
        DeprecationWarning
80
        )
2976.10.116 by Stuart Bishop
Fix and update tests
81
warnings.filterwarnings(
82
        'ignore', 'bzrlib.*was deprecated', DeprecationWarning
83
        )
2976.10.30 by Stuart Bishop
filter some test suite warnings
84
2976.10.61 by Stuart Bishop
Update warning filters
85
# This warning will be triggered if the beforeTraversal hook fails. We
86
# want to ensure it is not raised as an error, as this will mask the real
87
# problem.
88
warnings.filterwarnings(
89
        'always',
90
        re.escape('clear_request_started() called outside of a request'),
91
        UserWarning
92
        )
93
2976.10.30 by Stuart Bishop
filter some test suite warnings
94
# Any warnings not explicitly silenced are errors
95
warnings.filterwarnings('error', append=True)
96
1210 by Canonical.com Patch Queue Manager
Refactor and document test harnesses
97
1224 by Canonical.com Patch Queue Manager
Test isolation enforcement
98
from canonical.ftests import pgsql
1617 by Canonical.com Patch Queue Manager
Refactor PostgreSQL harnesses to avoid bug found by ddaa. Add more tests
99
# If this is removed, make sure canonical.ftests.pgsql is updated
100
# because the test harness there relies on the Connection wrapper being
101
# installed.
1224 by Canonical.com Patch Queue Manager
Test isolation enforcement
102
pgsql.installFakeConnect()
103
2976.10.19 by Stuart Bishop
Update test.py for Zope3.2
104
from zope.testing import testrunner
105
106
defaults = [
107
    # Find tests in the tests and ftests directories
108
    '--tests-pattern=^f?tests$',
109
    '--test-path=%s' % os.path.join(here, 'lib'),
110
    '--package=canonical',
111
    ]
1102 by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs
112
113
if __name__ == '__main__':
2976.10.19 by Stuart Bishop
Update test.py for Zope3.2
114
    result = testrunner.run(defaults)
115
    # Cribbed from sourcecode/zope/test.py - avoid spurious error during exit.
116
    logging.disable(999999999)
117
    sys.exit(result)
118