~abentley/bzrtools/bzrtools.dev

241 by Aaron Bentley
Added blackbox tests for bzrtools
1
from bzrlib.selftest.blackbox import ExternalBase
2
from unittest import makeSuite
3
import os.path
4
class TestBzrTools(ExternalBase):
5
    @staticmethod
6
    def touch(filename):
7
        file(filename, 'wb').write('')
8
9
    def test_clean_tree(self):
10
        self.runbzr('init')
11
        self.touch('name')
12
        self.touch('name~')
13
        assert os.path.lexists('name~')
14
        self.touch('name.pyc')
15
        self.runbzr('clean-tree')
16
        assert os.path.lexists('name~')
17
        assert not os.path.lexists('name')
265 by Aaron Bentley
Fixed spelling of detritus
18
        self.runbzr('clean-tree --detritus')
241 by Aaron Bentley
Added blackbox tests for bzrtools
19
        assert not os.path.lexists('name~')
20
        assert os.path.lexists('name.pyc')
21
        self.runbzr('clean-tree --ignored')
22
        assert not os.path.lexists('name.pyc')
23
24
    def test_shelve(self):
25
        self.runbzr('init')
26
        self.runbzr('commit -m uc --unchanged')
27
        self.runbzr('shelve -r 1 -m foo', retcode=1)
28
242 by Aaron Bentley
Added tests for patch and fetch-ghosts
29
    def test_fetch_ghosts(self):
30
        self.runbzr('init')
273 by Aaron Bentley
Adjusted tests to handle error status 3
31
        try:
32
            self.runbzr('fetch-ghosts .', retcode=1)
33
        except AssertionError:
34
            self.runbzr('fetch-ghosts .', retcode=3)
242 by Aaron Bentley
Added tests for patch and fetch-ghosts
35
36
    def test_patch(self):
37
        self.runbzr('init')
38
        file('myfile', 'wb').write('hello')
39
        self.runbzr('add')
40
        self.runbzr('commit -m hello')
41
        file('myfile', 'wb').write('goodbye')
271 by Aaron Bentley
Cherry-picked Robert's diff and push fixes
42
        file('mypatch', 'wb').write(self.runbzr('diff', retcode=1, backtick=1))
242 by Aaron Bentley
Added tests for patch and fetch-ghosts
43
        self.runbzr('revert')
44
        assert file('myfile', 'rb').read() == 'hello'
45
        self.runbzr('patch mypatch')
46
        assert file('myfile', 'rb').read() == 'goodbye'
47
48
241 by Aaron Bentley
Added blackbox tests for bzrtools
49
def test_suite():
50
    return makeSuite(TestBzrTools)