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

« back to all changes in this revision

Viewing changes to tests/test_prerequists.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:
89
89
        # unset sourceparts
90
90
        apt_pkg.config.set("Dir::Etc::sourceparts", tmpdir)
91
91
        # write empty status file
92
 
        open(tmpdir + "/status", "w")
 
92
        with open(tmpdir + "/status", "w") as f:
 
93
            f
93
94
        os.makedirs(tmpdir + "/lists/partial")
94
95
        apt_pkg.config.set("Dir::State", tmpdir)
95
96
        apt_pkg.config.set("Dir::State::status", tmpdir + "/status")
117
118
        template = os.path.join(self.testdir, "prerequists-sources.list.in")
118
119
        out = os.path.join(tmpdir, "prerequists-sources.list")
119
120
        # write empty status file
120
 
        open(tmpdir + "/status", "w")
 
121
        with open(tmpdir + "/status", "w") as f:
 
122
            f
121
123
        os.makedirs(tmpdir + "/lists/partial")
122
124
        apt_pkg.config.set("Dir::State", tmpdir)
123
125
        apt_pkg.config.set("Dir::State::status", tmpdir + "/status")
143
145
            "prerequists-sources.list.in.no_archive_falllback")
144
146
        out = os.path.join(tmpdir, "prerequists-sources.list")
145
147
        # write empty status file
146
 
        open(tmpdir + "/status", "w")
 
148
        with open(tmpdir + "/status", "w") as f:
 
149
            f
147
150
        os.makedirs(tmpdir + "/lists/partial")
148
151
        apt_pkg.config.set("Dir::State", tmpdir)
149
152
        apt_pkg.config.set("Dir::State::status", tmpdir + "/status")
168
171
                                "prerequists-sources.list.in.broken")
169
172
        out = os.path.join(tmpdir, "prerequists-sources.list")
170
173
        # write empty status file
171
 
        open(tmpdir + "/status", "w")
 
174
        with open(tmpdir + "/status", "w") as f:
 
175
            f
172
176
        os.makedirs(tmpdir + "/lists/partial")
173
177
        apt_pkg.config.set("Dir::State", tmpdir)
174
178
        apt_pkg.config.set("Dir::State::status", tmpdir + "/status")
181
185
        self.assertTrue(exp)
182
186
 
183
187
    def _verifySources(self, filename, expected):
184
 
        sources_list = open(filename).read()
 
188
        with open(filename) as f:
 
189
            sources_list = f.read()
185
190
        for l in expected.split("\n"):
186
191
            if l:
187
192
                self.assertTrue(l in sources_list,
188
193
                                "expected entry '%s' in '%s' missing, "
189
194
                                "got:\n%s" % (l, filename,
190
 
                                              open(filename).read()))
 
195
                                              sources_list))
191
196
 
192
197
if __name__ == "__main__":
193
198
    unittest.main()