def test_comment_out(self): tmpdir = tempfile.mkdtemp() sourceslist = os.path.join(tmpdir, "sources.list") open(sourceslist, "w") apt_pkg.config.set("dir::etc::sourcelist", sourceslist) apt_pkg.config.set("dir::state::lists", tmpdir) view = Mock() cdrom = AptCdrom(view, "./test-data-cdrom") cdrom.add() cdrom.comment_out_cdrom_entry() for line in open(sourceslist): self.assertTrue(line.startswith("#")) self.assertEqual(len(open(sourceslist).readlines()), 2)