~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shelf_tests.py

  • Committer: Aaron Bentley
  • Date: 2005-11-21 14:29:35 UTC
  • mfrom: (288 bzrtools)
  • mto: (147.4.24 trunk)
  • mto: This revision was merged to the branch mainline in revision 324.
  • Revision ID: abentley@panoramicfeedback.com-20051121142935-96c67761f8d04a12
Updated from mainline bzrtools

Show diffs side-by-side

added added

removed removed

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