~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_selftest.py

  • Committer: Danny van Heumen
  • Date: 2010-03-09 21:42:11 UTC
  • mto: (4634.139.5 2.0)
  • mto: This revision was merged to the branch mainline in revision 5160.
  • Revision ID: danny@dannyvanheumen.nl-20100309214211-iqh42x6qcikgd9p3
Reverted now-useless TODO list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
"""UI tests for the test framework."""
18
18
 
 
19
import bzrlib.transport
19
20
from bzrlib import (
 
21
    benchmarks,
20
22
    tests,
21
23
    )
 
24
from bzrlib.errors import ParamikoNotPresent
22
25
from bzrlib.tests import (
23
 
    features,
24
 
    )
25
 
from bzrlib.transport import memory
 
26
                          SubUnitFeature,
 
27
                          TestCase,
 
28
                          TestCaseInTempDir,
 
29
                          TestSkipped,
 
30
                          )
 
31
 
26
32
 
27
33
class SelfTestPatch:
28
34
 
45
51
            tests.selftest = original_selftest
46
52
 
47
53
 
48
 
class TestOptions(tests.TestCase, SelfTestPatch):
 
54
class TestOptionsWritingToDisk(TestCaseInTempDir, SelfTestPatch):
 
55
 
 
56
    def test_benchmark_runs_benchmark_tests(self):
 
57
        """selftest --benchmark should change the suite factory."""
 
58
        params = self.get_params_passed_to_core('selftest --benchmark')
 
59
        self.assertEqual(benchmarks.test_suite,
 
60
            params[1]['test_suite_factory'])
 
61
        self.assertNotEqual(None, params[1]['bench_history'])
 
62
        benchfile = open(".perf_history", "rt")
 
63
        try:
 
64
            lines = benchfile.readlines()
 
65
        finally:
 
66
            benchfile.close()
 
67
        # Because we don't run the actual test code no output is made to the
 
68
        # file.
 
69
        self.assertEqual(0, len(lines))
 
70
 
 
71
 
 
72
class TestOptions(TestCase, SelfTestPatch):
49
73
 
50
74
    def test_load_list(self):
51
75
        params = self.get_params_passed_to_core('selftest --load-list foo')
54
78
    def test_transport_set_to_sftp(self):
55
79
        # Test that we can pass a transport to the selftest core - sftp
56
80
        # version.
57
 
        self.requireFeature(features.paramiko)
58
 
        from bzrlib.tests import stub_sftp
 
81
        try:
 
82
            import bzrlib.transport.sftp
 
83
        except ParamikoNotPresent:
 
84
            raise TestSkipped("Paramiko not present")
59
85
        params = self.get_params_passed_to_core('selftest --transport=sftp')
60
 
        self.assertEqual(stub_sftp.SFTPAbsoluteServer,
 
86
        self.assertEqual(bzrlib.transport.sftp.SFTPAbsoluteServer,
61
87
            params[1]["transport"])
62
88
 
63
89
    def test_transport_set_to_memory(self):
64
90
        # Test that we can pass a transport to the selftest core - memory
65
91
        # version.
 
92
        import bzrlib.transport.memory
66
93
        params = self.get_params_passed_to_core('selftest --transport=memory')
67
 
        self.assertEqual(memory.MemoryServer, params[1]["transport"])
 
94
        self.assertEqual(bzrlib.transport.memory.MemoryServer,
 
95
            params[1]["transport"])
68
96
 
69
97
    def test_parameters_passed_to_core(self):
70
98
        params = self.get_params_passed_to_core('selftest --list-only')
88
116
        self.assertEqual(['foo', 'bar'], params[1]['starting_with'])
89
117
 
90
118
    def test_subunit(self):
91
 
        self.requireFeature(features.subunit)
 
119
        self.requireFeature(SubUnitFeature)
92
120
        params = self.get_params_passed_to_core('selftest --subunit')
93
121
        self.assertEqual(tests.SubUnitBzrRunner, params[1]['runner_class'])
94
122
 
144
172
            outputs_nothing(['selftest', '--list-only', '--exclude', 'selftest'])
145
173
        finally:
146
174
            tests.selftest = original_selftest
147
 
 
148
 
    def test_lsprof_tests(self):
149
 
        params = self.get_params_passed_to_core('selftest --lsprof-tests')
150
 
        self.assertEqual(True, params[1]["lsprof_tests"])