~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-05-05 08:29:29 UTC
  • mfrom: (1697.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060505082929-a037ee137f1ff240
Merge break-lock command.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
                          TestCaseInTempDir,
23
23
                          TestSkipped,
24
24
                          )
 
25
from bzrlib.tests.blackbox import ExternalBase
25
26
 
26
27
 
27
28
class TestOptions(TestCase):
73
74
            bzrlib.tests.default_transport = old_transport
74
75
            TestOptions.current_test = None
75
76
            TestCaseInTempDir.TEST_ROOT = old_root
 
77
 
 
78
 
 
79
class TestRunBzr(ExternalBase):
 
80
 
 
81
    def run_bzr_captured(self, argv, retcode=0, stdin=None):
 
82
        self.stdin = stdin
 
83
 
 
84
    def test_stdin(self):
 
85
        # test that the stdin keyword to run_bzr is passed through to
 
86
        # run_bzr_captured as-is. We do this by overriding
 
87
        # run_bzr_captured in this class, and then calling run_bzr,
 
88
        # which is a convenience function for run_bzr_captured, so 
 
89
        # should invoke it.
 
90
        self.run_bzr('foo', 'bar', stdin='gam')
 
91
        self.assertEqual('gam', self.stdin)
 
92
        self.run_bzr('foo', 'bar', stdin='zippy')
 
93
        self.assertEqual('zippy', self.stdin)
 
94
 
 
95
 
 
96
class TestRunBzrCaptured(ExternalBase):
 
97
 
 
98
    def apply_redirected(self, stdin=None, stdout=None, stderr=None,
 
99
                         a_callable=None, *args, **kwargs):
 
100
        self.stdin = stdin
 
101
        self.factory_stdin = getattr(bzrlib.ui.ui_factory, "stdin", None)
 
102
        return 0
 
103
 
 
104
    def test_stdin(self):
 
105
        # test that the stdin keyword to run_bzr_captured is passed through to
 
106
        # apply_redirected as a StringIO. We do this by overriding
 
107
        # apply_redirected in this class, and then calling run_bzr_captured,
 
108
        # which calls apply_redirected. 
 
109
        self.run_bzr_captured(['foo', 'bar'], stdin='gam')
 
110
        self.assertEqual('gam', self.stdin.read())
 
111
        self.assertTrue(self.stdin is self.factory_stdin)
 
112
        self.run_bzr_captured(['foo', 'bar'], stdin='zippy')
 
113
        self.assertEqual('zippy', self.stdin.read())
 
114
        self.assertTrue(self.stdin is self.factory_stdin)