~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shelf_tests.py

  • Committer: Aaron Bentley
  • Date: 2005-12-16 13:42:53 UTC
  • Revision ID: abentley@panoramicfeedback.com-20051216134253-632812e160315bc8
Updated test to match bzrlib

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
 
 
3
import bzrlib.tests
3
4
import os
4
 
 
5
 
import bzrlib.tests
6
 
 
7
 
 
8
5
class ShelfTests(bzrlib.tests.TestCaseInTempDir):
9
6
    ORIGINAL = '\n\nhello test world\n\n'
10
7
    MODIFIED = '\n\ngoodbye test world\n\n'
28
25
 
29
26
"""
30
27
    def test_shelf(self):
31
 
        from bzrlib.bzrdir import BzrDir
32
 
        tree = BzrDir.create_standalone_workingtree('.')
 
28
        from bzrlib.branch import Branch
 
29
        b = Branch.initialize('.')
33
30
 
34
31
        # Create a test file and commit it
35
32
        file('test_file', 'w').write(self.ORIGINAL)
36
 
        tree.add('test_file')
37
 
        tree.commit(message='add test_file')
 
33
        b.working_tree().add('test_file')
 
34
        b.working_tree().commit(message='add test_file')
38
35
 
39
36
        # Modify the test file
40
37
        file('test_file', 'w').write(self.MODIFIED)
68
65
 
69
66
    def test_shelf_nothing_to_shelve(self):
70
67
        import os.path
71
 
        from bzrlib.bzrdir import BzrDir
72
 
        tree = BzrDir.create_standalone_workingtree('.')
 
68
        from bzrlib.branch import Branch
 
69
        b = Branch.initialize('.')
73
70
 
74
71
        # Create a test file and commit it
75
72
        file('test_file', 'w').write(self.ORIGINAL)
76
 
        tree.add('test_file')
77
 
        tree.commit(message='add test_file')
 
73
        b.working_tree().add('test_file')
 
74
        b.working_tree().commit(message='add test_file')
78
75
 
79
76
        # Shelve the changes
80
77
        self.run_bzr('shelve', '--all')
83
80
            self.fail("Shelf exists, but it shouldn't")
84
81
 
85
82
    def test_shelf_with_revision(self):
86
 
        from bzrlib.bzrdir import BzrDir
87
 
        tree = BzrDir.create_standalone_workingtree('.')
 
83
        from bzrlib.branch import Branch
 
84
        b = Branch.initialize('.')
88
85
 
89
86
        # Create a test file and commit it
90
87
        file('test_file', 'w').write(self.ORIGINAL)
91
 
        tree.add('test_file')
92
 
        tree.commit(message='add test_file')
 
88
        b.working_tree().add('test_file')
 
89
        b.working_tree().commit(message='add test_file')
93
90
 
94
91
        # Modify the test file and commit it
95
92
        file('test_file', 'w').write(self.MODIFIED)
96
 
        tree.commit(message='update test_file')
 
93
        b.working_tree().commit(message='update test_file')
97
94
 
98
95
        # Shelve the changes
99
96
        self.run_bzr('shelve', '-r', '1', '--all', retcode=1)
112
109
        self.assertEqual(file('test_file').read(), self.MODIFIED)
113
110
 
114
111
    def test_shelf_with_two_revisions(self):
115
 
        from bzrlib.bzrdir import BzrDir
116
 
        tree = BzrDir.create_standalone_workingtree('.')
 
112
        from bzrlib.branch import Branch
 
113
        b = Branch.initialize('.')
117
114
 
118
115
        cmd = 'shelve -r 1..2'
119
116
        (stdout, stderr) = self.run_bzr_captured(cmd.split(), retcode=None)