~ubuntu-core-dev/ubuntu/xenial/ubuntu-release-upgrader/xenial

« back to all changes in this revision

Viewing changes to tests/test_quirks.py

  • Committer: Dimitri John Ledkov
  • Date: 2015-01-20 22:30:06 UTC
  • mto: This revision was merged to the branch mainline in revision 2859.
  • Revision ID: dimitri.j.ledkov@intel.com-20150120223006-ba30fbqtp4x2n0og
Fix resource warnings & logging.warn deprecation warning.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
        """ helper for test_patch to verify that we get the expected result """
41
41
        # simple case is foo
42
42
        patchdir = CURDIR + "/patchdir/"
43
 
        self.assertFalse("Hello" in open(patchdir + "foo").read())
44
 
        self.assertTrue("Hello" in open(patchdir + "foo_orig").read())
 
43
        with open(patchdir + "foo") as f:
 
44
            self.assertFalse("Hello" in f.read())
 
45
        with open(patchdir + "foo_orig") as f:
 
46
            self.assertTrue("Hello" in f.read())
45
47
        md5 = hashlib.md5()
46
48
        with open(patchdir + "foo", "rb") as patch:
47
49
            md5.update(patch.read())
62
64
            md5.update(patch.read())
63
65
        self.assertEqual(md5.hexdigest(), "cddc4be46bedd91db15ddb9f7ddfa804")
64
66
        # test that incorrect md5sum after patching rejects the patch
65
 
        self.assertEqual(open(patchdir + "fail").read(),
66
 
                         open(patchdir + "fail_orig").read())
 
67
        with open(patchdir + "fail") as f1, open(patchdir + "fail_orig") as f2:
 
68
            self.assertEqual(f1.read(),
 
69
                             f2.read())
67
70
 
68
71
    def test_patch(self):
69
72
        q = DistUpgradeQuirks(MockController(), MockConfig)