Esempio n. 1
0
    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")
Esempio n. 2
0
 def test_read_file(self):
     file_opener = config.File()
     the_file = file_opener(self.tempfile.name)
     self.assertEqual(the_file.read(), "test")
Esempio n. 3
0
 def test_no_file(self):
     file_opener = config.File()
     with self.assertRaises(ValueError):
         file_opener("/tmp/does_not_exist")