def test_use_pyfile(self): # First create the file. f = open(self.fname, 'wb') f2 = File(f) f2.write(self.data) f2.close() # Now read the file. f = open(self.fname, 'rb') data = f.read(len(self.data)) assert data == self.data
def test_use_pyfile(self): # First create the file. f = open(self.fname, 'wb') f2 = File(f) f2.write(self.data) f2.close() # Now read the file. with open(self.fname, 'rb') as f: data = f.read(len(self.data)) self.assertEqual(data, self.data)
def test_use_pyfile(self): # First create the file. with open(self.fname, 'wb') as f: f2 = File(f) f2.write(self.data) f2.close() # Now read the file. with open(self.fname, 'rb') as f: in_data = f.read(len(self.data)) self.assertEqual(len(in_data), len(self.data)) self.assertEqual(in_data, self.data)