~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shelf_tests.py

  • Committer: Aaron Bentley
  • Date: 2006-03-18 17:14:51 UTC
  • mfrom: (0.1.98 shelf)
  • Revision ID: aaron.bentley@utoronto.ca-20060318171451-2b15a9bcf7b77d69
Merge from shelf

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
            self.fail("Shelf exists, but it shouldn't")
90
90
 
91
91
    def __create_and_add_test_file(self, tree, filename='test_file'):
92
 
        self.build_tree_contents([(filename, self.ORIGINAL)])
93
 
        tree.add(filename)
 
92
        f = open(filename, 'w')
 
93
        f.write(self.ORIGINAL)
 
94
        f.close()
 
95
        tree.add(tree.relpath(os.path.join(os.getcwd(), filename)))
94
96
        tree.commit(message='add %s' % filename)
95
97
 
96
98
    def test_shelf_with_revision(self):
367
369
        # Check the diff is right
368
370
        self.assertEqual(self.capture('diff', retcode=1),
369
371
            self.DIFF_HEADER + self.DIFF_1 + '\n')
 
372
 
 
373
    def test_shelf_shelve_in_subdir(self):
 
374
        tree = self.make_branch_and_tree('.')
 
375
 
 
376
        self.__create_and_add_test_file(tree)
 
377
 
 
378
        # Modify the test file
 
379
        file('test_file', 'w').write(self.MODIFIED)
 
380
 
 
381
        # Shelve the changes
 
382
        self.run_bzr('shelve', '--all', retcode=0)
 
383
 
 
384
        # Working tree should be unchanged
 
385
        diff = self.capture('diff', retcode=0)
 
386
        self.assertEqual(diff, '')
 
387
 
 
388
        # Unshelve, should succeed
 
389
        self.run_bzr('unshelve', '--all', retcode=0)
 
390
 
 
391
        # Check the diff is right
 
392
        self.assertEqual(self.capture('diff', retcode=1),
 
393
            self.DIFF_HEADER + self.DIFF_1 + '\n')