~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shelf_tests.py

  • Committer: Aaron Bentley
  • Date: 2005-12-03 20:42:25 UTC
  • mfrom: (147.4.25 trunk)
  • mto: (147.4.27 trunk)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: aaron.bentley@utoronto.ca-20051203204225-25678bc921de4fc1
MergeĀ fromĀ lifeless

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
 
3
 
import bzrlib.selftest
4
3
import os
5
 
class ShelfTests(bzrlib.selftest.TestCaseInTempDir):
 
4
 
 
5
import bzrlib.tests
 
6
 
 
7
 
 
8
class ShelfTests(bzrlib.tests.TestCaseInTempDir):
6
9
    ORIGINAL = '\n\nhello test world\n\n'
7
10
    MODIFIED = '\n\ngoodbye test world\n\n'
8
11
    DIFF_HEADER = "=== modified file 'test_file'\n"
26
29
"""
27
30
    def test_shelf(self):
28
31
        from bzrlib.branch import Branch
 
32
        from bzrlib.workingtree import WorkingTree
29
33
        b = Branch.initialize('.')
 
34
        tree = WorkingTree(b.base, b)
30
35
 
31
36
        # Create a test file and commit it
32
37
        file('test_file', 'w').write(self.ORIGINAL)
33
 
        b.add('test_file')
34
 
        b.working_tree().commit(message='add test_file')
 
38
        tree.add('test_file')
 
39
        tree.commit(message='add test_file')
35
40
 
36
41
        # Modify the test file
37
42
        file('test_file', 'w').write(self.MODIFIED)
64
69
        self.assertEqual(file('test_file').read(), self.MODIFIED)
65
70
 
66
71
    def test_shelf_nothing_to_shelve(self):
67
 
        import os.path
68
72
        from bzrlib.branch import Branch
 
73
        from bzrlib.workingtree import WorkingTree
69
74
        b = Branch.initialize('.')
 
75
        tree = WorkingTree(b.base, b)
70
76
 
71
77
        # Create a test file and commit it
72
78
        file('test_file', 'w').write(self.ORIGINAL)
73
 
        b.add('test_file')
74
 
        b.working_tree().commit(message='add test_file')
 
79
        tree.add('test_file')
 
80
        tree.commit(message='add test_file')
75
81
 
76
82
        # Shelve the changes
77
83
        self.run_bzr('shelve', '--all')
81
87
 
82
88
    def test_shelf_with_revision(self):
83
89
        from bzrlib.branch import Branch
 
90
        from bzrlib.workingtree import WorkingTree
84
91
        b = Branch.initialize('.')
 
92
        tree = WorkingTree(b.base, b)
85
93
 
86
94
        # Create a test file and commit it
87
95
        file('test_file', 'w').write(self.ORIGINAL)
88
 
        b.add('test_file')
89
 
        b.working_tree().commit(message='add test_file')
 
96
        tree.add('test_file')
 
97
        tree.commit(message='add test_file')
90
98
 
91
99
        # Modify the test file and commit it
92
100
        file('test_file', 'w').write(self.MODIFIED)
93
 
        b.working_tree().commit(message='update test_file')
 
101
        tree.commit(message='update test_file')
94
102
 
95
103
        # Shelve the changes
96
104
        self.run_bzr('shelve', '-r', '1', '--all', retcode=1)