bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
5452.4.3
by John Arbash Meinel
 Merge bzr.dev to resolve bzr-2.3.txt (aka NEWS)  | 
1  | 
# Copyright (C) 2010 Canonical Ltd
 | 
| 
5510.1.2
by Martin von Gagern
 Avoid test-script command depending on testtools.  | 
2  | 
#
 | 
3  | 
# This program is free software; you can redistribute it and/or modify
 | 
|
4  | 
# it under the terms of the GNU General Public License as published by
 | 
|
5  | 
# the Free Software Foundation; either version 2 of the License, or
 | 
|
6  | 
# (at your option) any later version.
 | 
|
7  | 
#
 | 
|
8  | 
# This program is distributed in the hope that it will be useful,
 | 
|
9  | 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|
10  | 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|
11  | 
# GNU General Public License for more details.
 | 
|
12  | 
#
 | 
|
13  | 
# You should have received a copy of the GNU General Public License
 | 
|
14  | 
# along with this program; if not, write to the Free Software
 | 
|
15  | 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 | 
|
16  | 
||
17  | 
"""Front-end command for shell-like test scripts.
 | 
|
18  | 
||
| 
5531.1.2
by Vincent Ladeuil
 s/blank_output/null_output/  | 
19  | 
See doc/developers/testing.txt for more explanations.
 | 
| 
5510.1.2
by Martin von Gagern
 Avoid test-script command depending on testtools.  | 
20  | 
This module should be importable even if testtools aren't available.
 | 
21  | 
"""
 | 
|
22  | 
||
| 
6379.6.7
by Jelmer Vernooij
 Move importing from future until after doc string, otherwise the doc string will disappear.  | 
23  | 
from __future__ import absolute_import  | 
24  | 
||
| 
5510.1.2
by Martin von Gagern
 Avoid test-script command depending on testtools.  | 
25  | 
import os  | 
26  | 
||
| 
6624
by Jelmer Vernooij
 Merge Python3 porting work ('py3 pokes')  | 
27  | 
from . import (  | 
| 
5531.1.3
by Vincent Ladeuil
 Implements --null-ouput for the test-script command.  | 
28  | 
commands,  | 
29  | 
option,  | 
|
30  | 
    )
 | 
|
| 
5510.1.2
by Martin von Gagern
 Avoid test-script command depending on testtools.  | 
31  | 
|
| 
5510.1.4
by Martin von Gagern
 Minor polishing suggested by John A Meinel.  | 
32  | 
|
| 
5510.1.2
by Martin von Gagern
 Avoid test-script command depending on testtools.  | 
33  | 
class cmd_test_script(commands.Command):  | 
34  | 
"""Run a shell-like test from a file."""  | 
|
35  | 
||
36  | 
hidden = True  | 
|
37  | 
takes_args = ['infile']  | 
|
| 
5531.1.3
by Vincent Ladeuil
 Implements --null-ouput for the test-script command.  | 
38  | 
takes_options = [  | 
39  | 
option.Option('null-output',  | 
|
40  | 
help='Null command outputs match any output.'),  | 
|
41  | 
        ]
 | 
|
| 
5510.1.2
by Martin von Gagern
 Avoid test-script command depending on testtools.  | 
42  | 
|
43  | 
@commands.display_command  | 
|
| 
5531.1.3
by Vincent Ladeuil
 Implements --null-ouput for the test-script command.  | 
44  | 
def run(self, infile, null_output=False):  | 
| 
5510.1.4
by Martin von Gagern
 Minor polishing suggested by John A Meinel.  | 
45  | 
        # local imports to defer testtools dependency
 | 
| 
6622.1.34
by Jelmer Vernooij
 Rename brzlib => breezy.  | 
46  | 
from breezy import tests  | 
47  | 
from breezy.tests.script import TestCaseWithTransportAndScript  | 
|
| 
5510.1.2
by Martin von Gagern
 Avoid test-script command depending on testtools.  | 
48  | 
|
| 
6855.4.5
by Jelmer Vernooij
 Fix more bees, use with rather than try/finally for some files.  | 
49  | 
with open(infile) as f:  | 
| 
5510.1.2
by Martin von Gagern
 Avoid test-script command depending on testtools.  | 
50  | 
script = f.read()  | 
51  | 
||
52  | 
class Test(TestCaseWithTransportAndScript):  | 
|
53  | 
||
54  | 
script = None # Set before running  | 
|
55  | 
||
56  | 
def test_it(self):  | 
|
| 
5531.1.3
by Vincent Ladeuil
 Implements --null-ouput for the test-script command.  | 
57  | 
self.run_script(script,  | 
58  | 
null_output_matches_anything=null_output)  | 
|
| 
5510.1.2
by Martin von Gagern
 Avoid test-script command depending on testtools.  | 
59  | 
|
60  | 
runner = tests.TextTestRunner(stream=self.outf)  | 
|
61  | 
test = Test('test_it')  | 
|
62  | 
test.path = os.path.realpath(infile)  | 
|
63  | 
res = runner.run(test)  | 
|
64  | 
return len(res.errors) + len(res.failures)  |