~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: Matt McClure
  • Date: 2008-04-28 22:35:26 UTC
  • mto: (3452.1.1 bzr.dev.mlm)
  • mto: This revision was merged to the branch mainline in revision 3493.
  • Revision ID: mlm@aya.yale.edu-20080428223526-mi721m30pvw1ghey
Reverts to prior decomposition of exercise and verification, as suggested
by abentley.  Renames the test method accordingly.  Extracts a method for
the formerly repeated verification idiom.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1291
1291
        self.assertEqual('a-tool-which-is-unlikely-to-exist could not be found'
1292
1292
                         ' on this machine', str(e))
1293
1293
 
1294
 
    def test_windows_tool_reads_both_files(self):
 
1294
    def test_prepare_files_creates_paths_readable_by_windows_tool(self):
1295
1295
        self.requireFeature(AttribFeature)
1296
1296
        output = StringIO()
1297
1297
        tree = self.make_branch_and_tree('tree')
1301
1301
        tree.lock_read()
1302
1302
        self.addCleanup(tree.unlock)
1303
1303
        diff_obj = DiffFromTool(['python', '-c',
1304
 
                                 """
1305
 
import subprocess
1306
 
proc = subprocess.Popen(["attrib", "%(old_path)s"],
1307
 
                        stdout=subprocess.PIPE)
1308
 
proc.wait()
1309
 
print proc.stdout.read()
1310
 
proc = subprocess.Popen(["attrib", "%(new_path)s"],
1311
 
                        stdout=subprocess.PIPE)
1312
 
proc.wait()
1313
 
print proc.stdout.read()
1314
 
"""
1315
 
                                 ],
1316
 
                                 tree, tree, output)
1317
 
        diff_obj.diff('file-id', 'file', 'file', 'file', 'file')
1318
 
        lines = output.getvalue()
1319
 
        self.assertContainsRe(lines, r'old\\file')
1320
 
        self.assertContainsRe(lines, r'new\\file')
 
1304
                                 'print "%(old_path)s %(new_path)s"'],
 
1305
                                tree, tree, output)
 
1306
        diff_obj._prepare_files('file-id', 'file', 'file')
 
1307
        self.assertReadableByAttrib(diff_obj._root, 'old\\file', r'old\\file')
 
1308
        self.assertReadableByAttrib(diff_obj._root, 'new\\file', r'new\\file')
 
1309
 
 
1310
    def assertReadableByAttrib(self, cwd, relpath, regex):
 
1311
        proc = subprocess.Popen(['attrib', relpath],
 
1312
                                stdout=subprocess.PIPE,
 
1313
                                cwd=cwd)
 
1314
        proc.wait()
 
1315
        result=proc.stdout.read()
 
1316
        self.assertContainsRe(result, regex)
1321
1317
 
1322
1318
    def test_prepare_files(self):
1323
1319
        output = StringIO()