def testBytesOpen(self): # Opening a bytes filename try: fn = TESTFN.encode("ascii") except UnicodeEncodeError: # Skip test return f = self.f = _FileIO(fn, "w") f.write(b"abc") f.close() with open(TESTFN, "rb") as f: self.f = f self.assertEqual(f.read(), b"abc")
def testBytesOpen(self): try: fn = TESTFN.encode('ascii') except UnicodeEncodeError: self.skipTest('could not encode %r to ascii' % TESTFN) f = self.FileIO(fn, 'w') try: f.write(b'abc') f.close() with open(TESTFN, 'rb') as f: self.assertEqual(f.read(), b'abc') finally: os.unlink(TESTFN)
def testBytesOpen(self): # Opening a bytes filename try: fn = TESTFN.encode("ascii") except UnicodeEncodeError: self.skipTest('could not encode %r to ascii' % TESTFN) f = self.FileIO(fn, "w") try: f.write(b"abc") f.close() with open(TESTFN, "rb") as f: self.assertEqual(f.read(), b"abc") finally: os.unlink(TESTFN)
def testBytesOpen(self): # Opening a bytes filename try: fn = TESTFN.encode("ascii") except UnicodeEncodeError: self.skipTest('could not encode %r to ascii' % TESTFN) f = _FileIO(fn, "w") try: f.write(b"abc") f.close() with open(TESTFN, "rb") as f: self.assertEqual(f.read(), b"abc") finally: os.unlink(TESTFN)