diff options
author | Tim Peters <tim.peters@gmail.com> | 2006-05-26 13:39:17 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2006-05-26 13:39:17 (GMT) |
commit | b1f3251ceb07af3a3915f2fa2bd8cb106fa0f23a (patch) | |
tree | 7006cd0251274b8e86a75ffbcddc7a5076ca6ffd /Lib | |
parent | e27337b5d01a63f6874382175221936780e50acd (diff) | |
download | cpython-b1f3251ceb07af3a3915f2fa2bd8cb106fa0f23a.zip cpython-b1f3251ceb07af3a3915f2fa2bd8cb106fa0f23a.tar.gz cpython-b1f3251ceb07af3a3915f2fa2bd8cb106fa0f23a.tar.bz2 |
Use open() to open files (was using file()).
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_tarfile.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index 503de26..ef485af 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -87,7 +87,7 @@ class ReadTest(BaseTest): if self.sep != "|": filename = "0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) - lines1 = file(os.path.join(dirname(), filename), "rU").readlines() + lines1 = open(os.path.join(dirname(), filename), "rU").readlines() lines2 = self.tar.extractfile(filename).readlines() self.assert_(lines1 == lines2, "_FileObject.readline() does not work correctly") @@ -97,7 +97,7 @@ class ReadTest(BaseTest): if self.sep != "|": filename = "0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) - lines1 = file(os.path.join(dirname(), filename), "rU").readlines() + lines1 = open(os.path.join(dirname(), filename), "rU").readlines() lines2 = [line for line in self.tar.extractfile(filename)] self.assert_(lines1 == lines2, "ExFileObject iteration does not work correctly") @@ -108,7 +108,7 @@ class ReadTest(BaseTest): if self.sep != "|": filename = "0-REGTYPE" self.tar.extract(filename, dirname()) - data = file(os.path.join(dirname(), filename), "rb").read() + data = open(os.path.join(dirname(), filename), "rb").read() tarinfo = self.tar.getmember(filename) fobj = self.tar.extractfile(tarinfo) @@ -156,7 +156,7 @@ class ReadTest(BaseTest): tarinfo = tarfile.TarInfo("directory/") tarinfo.type = tarfile.REGTYPE - fobj = file(filename, "w") + fobj = open(filename, "w") fobj.write(tarinfo.tobuf()) fobj.close() @@ -286,10 +286,10 @@ class WriteSize0Test(BaseTest): def test_file(self): path = os.path.join(self.tmpdir, "file") - file(path, "w") + open(path, "w") tarinfo = self.dst.gettarinfo(path) self.assertEqual(tarinfo.size, 0) - file(path, "w").write("aaa") + open(path, "w").write("aaa") tarinfo = self.dst.gettarinfo(path) self.assertEqual(tarinfo.size, 3) @@ -440,7 +440,7 @@ class ReadGNULongTest(unittest.TestCase): self.assert_(tarinfo.linkname == name, "linkname wrong") def test_truncated_longname(self): - fobj = StringIO.StringIO(file(tarname()).read(1024)) + fobj = StringIO.StringIO(open(tarname()).read(1024)) tar = tarfile.open(name="foo.tar", fileobj=fobj) self.assert_(len(tar.getmembers()) == 0, "") @@ -480,7 +480,7 @@ class CreateHardlinkTest(BaseTest): if os.path.exists(self.bar): os.remove(self.bar) - file(self.foo, "w").write("foo") + open(self.foo, "w").write("foo") self.tar.add(self.foo) def test_add_twice(self): @@ -565,10 +565,10 @@ if not gzip: def test_main(): if gzip: # create testtar.tar.gz - gzip.open(tarname("gz"), "wb").write(file(tarname(), "rb").read()) + gzip.open(tarname("gz"), "wb").write(open(tarname(), "rb").read()) if bz2: # create testtar.tar.bz2 - bz2.BZ2File(tarname("bz2"), "wb").write(file(tarname(), "rb").read()) + bz2.BZ2File(tarname("bz2"), "wb").write(open(tarname(), "rb").read()) tests = [ FileModeTest, |