~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/__init__.py

  • Committer: Martin Pool
  • Date: 2005-06-22 06:18:20 UTC
  • Revision ID: mbp@sourcefrog.net-20050622061820-9f5613de173e6ab2
- move more tests into bzr selftest

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
                                % (cmd, actual_retcode, retcode))
77
77
 
78
78
 
 
79
    def backtick(self, cmd, retcode=0):
 
80
        cmd = self.formcmd(cmd)
 
81
        child = Popen(cmd, stdout=PIPE, stderr=self.TEST_LOG)
 
82
        outd, errd = child.communicate()
 
83
        self.log(outd)
 
84
        actual_retcode = child.wait()
 
85
 
 
86
        outd = outd.replace('\r', '')
 
87
 
 
88
        if retcode != actual_retcode:
 
89
            raise CommandFailed("test failed: %r returned %d, expected %d"
 
90
                                % (cmd, actual_retcode, retcode))
 
91
 
 
92
        return outd
 
93
 
 
94
 
 
95
 
79
96
 
80
97
    def log(self, msg):
81
98
        """Log a message to a progress file"""
82
99
        print >>self.TEST_LOG, msg
83
100
               
84
101
 
 
102
class InTempDir(TestBase):
 
103
    """Base class for tests run in a temporary branch."""
 
104
    def setUp(self):
 
105
        import os
 
106
        self.branch_dir = os.path.join(self.TEST_DIR, self.__class__.__name__)
 
107
        os.mkdir(self.branch_dir)
 
108
        os.chdir(self.branch_dir)
 
109
        
 
110
    def tearDown(self):
 
111
        import os
 
112
        os.chdir(self.TEST_DIR)
 
113
 
 
114
 
 
115
 
85
116
 
86
117
 
87
118
class _MyResult(TestResult):