~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_versioning.py

  • Committer: Vincent Ladeuil
  • Date: 2007-06-26 20:32:49 UTC
  • mto: (2581.1.1 cleanup-runbzr)
  • mto: This revision was merged to the branch mainline in revision 2588.
  • Revision ID: v.ladeuil+lp@free.fr-20070626203249-sqm4afiai5dxofum
Deprecate the varargs syntax and fix the tests.

* bzrlib/tests/__init__.py:
(TestCase.run_bzr): Activate the deprecation warning.
(TestCase.run_bzr_error): Add error_regexes to kwargs or run_bzr
get confused.

* bzrlib/tests/blackbox/test_selftest.py:
(TestRunBzr.test_args): Activate.

* bzrlib/tests/blackbox/test_inventory.py:
(TestInventory.assertInventoryEqual): Build the command from args
if not None.

* bzrlib/tests/blackbox/test_ls.py:
(TestLS.ls_equals): Build the command from args if not None.

* bzrlib/tests/blackbox/test_remove_tree.py:
(TestRemoveTree.test_remove_tree_lightweight_checkout_explicit):
Nice catch, we were calling run_bzr instead of run_bzr_error. This
went unnoticed for some time...

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
 
32
32
class TestVersioning(TestCaseInTempDir):
33
 
    
34
 
    def test_mkdir(self): 
 
33
 
 
34
    def test_mkdir(self):
35
35
        """Basic 'bzr mkdir' operation"""
36
36
 
37
37
        self.run_bzr('init')
38
 
        self.run_bzr('mkdir', 'foo')
 
38
        self.run_bzr('mkdir foo')
39
39
        self.assert_(os.path.isdir('foo'))
40
40
 
41
 
        self.run_bzr('mkdir', 'foo', retcode=3)
 
41
        self.run_bzr('mkdir foo', retcode=3)
42
42
 
43
43
        wt = WorkingTree.open('.')
44
 
        
 
44
 
45
45
        delta = wt.changes_from(wt.basis_tree())
46
46
 
47
47
        self.log('delta.added = %r' % delta.added)
54
54
        """'bzr mkdir' operation in subdirectory"""
55
55
 
56
56
        self.run_bzr('init')
57
 
        self.run_bzr('mkdir', 'dir')
 
57
        self.run_bzr('mkdir dir')
58
58
        self.assert_(os.path.isdir('dir'))
59
59
 
60
60
        os.chdir('dir')
61
61
        self.log('Run mkdir in subdir')
62
 
        self.run_bzr('mkdir', 'subdir')
 
62
        self.run_bzr('mkdir subdir')
63
63
        self.assert_(os.path.isdir('subdir'))
64
64
        os.chdir('..')
65
65
 
66
66
        wt = WorkingTree.open('.')
67
 
        
 
67
 
68
68
        delta = wt.changes_from(wt.basis_tree())
69
69
 
70
70
        self.log('delta.added = %r' % delta.added)
86
86
        self.run_bzr('init')
87
87
        os.chdir('../..')
88
88
 
89
 
        self.run_bzr('mkdir', 'dir', 'a/dir', 'a/b/dir')
 
89
        self.run_bzr('mkdir dir a/dir a/b/dir')
90
90
        self.failUnless(os.path.isdir('dir'))
91
91
        self.failUnless(os.path.isdir('a/dir'))
92
92
        self.failUnless(os.path.isdir('a/b/dir'))
94
94
        wt = WorkingTree.open('.')
95
95
        wt_a = WorkingTree.open('a')
96
96
        wt_b = WorkingTree.open('a/b')
97
 
        
 
97
 
98
98
        delta = wt.changes_from(wt.basis_tree())
99
99
        self.assertEquals(len(delta.added), 1)
100
100
        self.assertEquals(delta.added[0][0], 'dir')
116
116
        The upgrade should be a no-op."""
117
117
        b = Branch.open(u'.')
118
118
        mutter('branch has %d revisions', b.revno())
119
 
        
 
119
 
120
120
        mutter('check branch...')
121
121
        from bzrlib.check import check
122
122
        check(b, False)
130
130
        eq = self.assertEqual
131
131
 
132
132
        self.build_tree(['a/', 'b/'])
133
 
        
 
133
 
134
134
        run_bzr('init')
135
135
        b = Branch.open(u'.')
136
 
        
 
136
 
137
137
        for fn in ('a/one', 'b/two', 'top'):
138
138
            file(fn, 'w').write('old contents')
139
 
            
 
139
 
140
140
        run_bzr('add')
141
 
        run_bzr('commit', '-m', 'first revision')
142
 
        
 
141
        run_bzr('commit -m first_revision')
 
142
 
143
143
        for fn in ('a/one', 'b/two', 'top'):
144
144
            file(fn, 'w').write('new contents')
145
 
            
 
145
 
146
146
        mutter('start selective subdir commit')
147
 
        run_bzr('commit', 'a', '-m', 'commit a only')
148
 
        
 
147
        run_bzr('commit a -m commit_a_only')
 
148
 
149
149
        old = b.repository.revision_tree(b.get_rev_id(1))
150
150
        new = b.repository.revision_tree(b.get_rev_id(2))
151
 
        
 
151
 
152
152
        eq(new.get_file_by_path('b/two').read(), 'old contents')
153
153
        eq(new.get_file_by_path('top').read(), 'old contents')
154
154
        eq(new.get_file_by_path('a/one').read(), 'new contents')
155
 
        
 
155
 
156
156
        os.chdir('a')
157
157
        # commit from here should do nothing
158
 
        run_bzr('commit', '.', '-m', 'commit subdir only', '--unchanged')
 
158
        run_bzr('commit . -m commit_subdir_only --unchanged')
159
159
        v3 = b.repository.revision_tree(b.get_rev_id(3))
160
160
        eq(v3.get_file_by_path('b/two').read(), 'old contents')
161
161
        eq(v3.get_file_by_path('top').read(), 'old contents')
162
162
        eq(v3.get_file_by_path('a/one').read(), 'new contents')
163
 
                
 
163
 
164
164
        # commit in subdirectory commits whole tree
165
 
        run_bzr('commit', '-m', 'commit whole tree from subdir')
 
165
        run_bzr('commit -m commit_whole_tree_from_subdir')
166
166
        v4 = b.repository.revision_tree(b.get_rev_id(4))
167
 
        eq(v4.get_file_by_path('b/two').read(), 'new contents')        
 
167
        eq(v4.get_file_by_path('b/two').read(), 'new contents')
168
168
        eq(v4.get_file_by_path('top').read(), 'new contents')
169
 
        
 
169
 
170
170
        # TODO: factor out some kind of assert_tree_state() method
171
 
        
 
171
 
172
172
 
173
173
if __name__ == '__main__':
174
174
    import unittest
175
175
    unittest.main()
176