~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2006-05-04 01:31:48 UTC
  • mto: (1697.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1701.
  • Revision ID: robertc@robertcollins.net-20060504013148-74208691b1b4857e
Add stdin parameter to run_bzr and run_bzr_captured.

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.
 
87
        self.run_bzr('foo', 'bar', stdin='gam')
 
88
        self.assertEqual('gam', self.stdin)
 
89
        self.run_bzr('foo', 'bar', stdin='zippy')
 
90
        self.assertEqual('zippy', self.stdin)
 
91
 
 
92
 
 
93
class TestRunBzrCaptured(ExternalBase):
 
94
 
 
95
    def apply_redirected(self, stdin=None, stdout=None, stderr=None,
 
96
                         a_callable=None, *args, **kwargs):
 
97
        self.stdin = stdin
 
98
        return 0
 
99
 
 
100
    def test_stdin(self):
 
101
        # test that the stdin keyword to run_bzr_captured is passed through to
 
102
        # apply_redirected as a StringIO
 
103
        self.run_bzr_captured(['foo', 'bar'], stdin='gam')
 
104
        self.assertEqual('gam', self.stdin.read())
 
105
        self.run_bzr_captured(['foo', 'bar'], stdin='zippy')
 
106
        self.assertEqual('zippy', self.stdin.read())