def test_write_file(self): file_opener = config.File(mode="w") the_file = file_opener(self.tempfile.name) the_file.write("cool") the_file.close() with open(self.tempfile.name) as f: self.assertEqual(f.read(), "cool")
def test_read_file(self): file_opener = config.File() the_file = file_opener(self.tempfile.name) self.assertEqual(the_file.read(), "test")
def test_no_file(self): file_opener = config.File() with self.assertRaises(ValueError): file_opener("/tmp/does_not_exist")