bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1185.51.1
by Martin Pool
Better message when failing to import a test suite. |
1 |
# Copyright (C) 2005 by Canonical Ltd
|
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 version 2 as published by
|
|
5 |
# the Free Software Foundation.
|
|
6 |
#
|
|
7 |
# This program is distributed in the hope that it will be useful,
|
|
8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
# GNU General Public License for more details.
|
|
11 |
#
|
|
12 |
# You should have received a copy of the GNU General Public License
|
|
13 |
# along with this program; if not, write to the Free Software
|
|
14 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15 |
||
16 |
"""Tests for the test framework
|
|
17 |
"""
|
|
18 |
||
19 |
import os |
|
20 |
import sys |
|
|
1185.33.95
by Martin Pool
New TestSkipped facility, and tests for it. |
21 |
import unittest |
|
1185.51.1
by Martin Pool
Better message when failing to import a test suite. |
22 |
|
|
1185.33.95
by Martin Pool
New TestSkipped facility, and tests for it. |
23 |
from bzrlib.tests import TestCase, _load_module_by_name, \ |
24 |
TestSkipped
|
|
25 |
import bzrlib.tests |
|
|
1185.51.1
by Martin Pool
Better message when failing to import a test suite. |
26 |
|
27 |
||
28 |
class SelftestTests(TestCase): |
|
29 |
||
30 |
def test_import_tests(self): |
|
31 |
mod = _load_module_by_name('bzrlib.tests.test_selftest') |
|
32 |
self.assertEqual(mod.SelftestTests, SelftestTests) |
|
33 |
||
34 |
def test_import_test_failure(self): |
|
35 |
self.assertRaises(ImportError, |
|
36 |
_load_module_by_name, |
|
37 |
'bzrlib.no-name-yet') |
|
38 |
||
39 |
||
40 |
class MetaTestLog(TestCase): |
|
41 |
def test_logging(self): |
|
42 |
"""Test logs are captured when a test fails.""" |
|
43 |
self.log('a test message') |
|
44 |
self._log_file.flush() |
|
45 |
self.assertContainsRe(self._get_log(), 'a test message\n') |
|
|
1185.33.95
by Martin Pool
New TestSkipped facility, and tests for it. |
46 |
|
47 |
||
48 |
class TestSkippedTest(TestCase): |
|
49 |
"""Try running a test which is skipped, make sure it's reported properly.""" |
|
50 |
def test_skipped_test(self): |
|
51 |
# must be hidden in here so it's not run as a real test
|
|
52 |
def skipping_test(): |
|
53 |
raise TestSkipped('test intentionally skipped') |
|
54 |
runner = bzrlib.tests.TextTestRunner(stream=self._log_file) |
|
55 |
test = unittest.FunctionTestCase(skipping_test) |
|
56 |
result = runner.run(test) |
|
57 |
self.assertTrue(result.wasSuccessful()) |