~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/versioning.py

  • Committer: Martin Pool
  • Date: 2005-08-24 02:34:24 UTC
  • Revision ID: mbp@sourcefrog.net-20050824023424-67667e2b57c3d7d0
- merge test refactoring from robertc

  More of the common test infrastructure to do with 
  making temporary directories, etc, is now done from a 
  TestCase subclass, and generally have less magic
  compared to unittest. 

robertc@robertcollins.net-20050823111339-fb55b8ce170b20e0

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib.branch import Branch
27
27
 
28
28
 
29
 
class Mkdir(InTempDir):
30
 
    def runTest(self): 
 
29
class TestVersioning(InTempDir):
 
30
    
 
31
    def test_mkdir(self): 
31
32
        """Basic 'bzr mkdir' operation"""
32
33
        from bzrlib.commands import run_bzr
33
34
 
49
50
        self.assertEquals(delta.added[0][0], 'foo')
50
51
        self.failIf(delta.modified)
51
52
 
52
 
 
53
 
 
54
 
class AddInUnversioned(InTempDir):
55
 
    def runTest(self):
 
53
    def test_add_in_unversioned(self):
56
54
        """Try to add a file in an unversioned directory.
57
55
 
58
56
        smart_add may eventually add the parent as necessary, but simple
70
68
                          b.add,
71
69
                          'foo/hello')
72
70
        
 
71
    def test_subdir_add(self):
 
72
        """Add in subdirectory should add only things from there down"""
 
73
        
 
74
        from bzrlib.branch import Branch
 
75
        from bzrlib.commands import run_bzr
 
76
        
 
77
        eq = self.assertEqual
 
78
        ass = self.assert_
 
79
        chdir = os.chdir
 
80
        
 
81
        b = Branch('.', init=True)
 
82
        self.build_tree(['src/', 'README'])
 
83
        
 
84
        eq(sorted(b.unknowns()),
 
85
           ['README', 'src'])
 
86
        
 
87
        eq(run_bzr(['add', 'src']), 0)
 
88
        
 
89
        self.build_tree(['src/foo.c'])
 
90
        
 
91
        chdir('src')
 
92
        eq(run_bzr(['add']), 0)
 
93
        
 
94
        eq(sorted(b.unknowns()), 
 
95
           ['README'])
 
96
        eq(len(b.inventory), 3)
 
97
                
 
98
        chdir('..')
 
99
        eq(run_bzr(['add']), 0)
 
100
        eq(list(b.unknowns()), [])
 
101
        
73
102
        
74
103
class SubdirCommit(BzrTestBase):
75
 
    def runTest(self):
 
104
 
 
105
    def test_subdir_commit(self):
76
106
        """Test committing a subdirectory, and committing within a directory."""
77
107
        run_bzr = self.run_bzr
78
108
        eq = self.assertEqual
116
146
        
117
147
        # TODO: factor out some kind of assert_tree_state() method
118
148
        
119
 
        
120
 
        
121
 
class SubdirAdd(InTempDir):
122
 
    def runTest(self):
123
 
        """Add in subdirectory should add only things from there down"""
124
 
        
125
 
        from bzrlib.branch import Branch
126
 
        from bzrlib.commands import run_bzr
127
 
        
128
 
        eq = self.assertEqual
129
 
        ass = self.assert_
130
 
        chdir = os.chdir
131
 
        
132
 
        b = Branch('.', init=True)
133
 
        self.build_tree(['src/', 'README'])
134
 
        
135
 
        eq(sorted(b.unknowns()),
136
 
           ['README', 'src'])
137
 
        
138
 
        eq(run_bzr(['add', 'src']), 0)
139
 
        
140
 
        self.build_tree(['src/foo.c'])
141
 
        
142
 
        chdir('src')
143
 
        eq(run_bzr(['add']), 0)
144
 
        
145
 
        eq(sorted(b.unknowns()), 
146
 
           ['README'])
147
 
        eq(len(b.inventory), 3)
148
 
                
149
 
        chdir('..')
150
 
        eq(run_bzr(['add']), 0)
151
 
        eq(list(b.unknowns()), [])
152