def test_it_should_support_utf8_content_on_temporary_file(self): filename = None try: filename = Utils.write_temporary_file('content çáéíóú'.decode('utf-8'), 'content_reference') self.assertEqual(open(filename, "r").read(), 'content çáéíóú') finally: if filename and os.path.exists(filename): os.unlink(filename)
def test_it_should_create_a_temporary_file_with_the_given_content(self): filename = None try: filename = Utils.write_temporary_file('content', 'content_reference') self.assertTrue(filename.index('/tmp/') == 0) self.assertEqual(open(filename, "r").read(), 'content') finally: if filename and os.path.exists(filename): os.unlink(filename)
def test_it_should_raise_exception_when_an_error_happens_on_writing_temporary_file(self, named_temporary_file_mock): try: Utils.write_temporary_file('content', 'content_reference') self.fail("it should not get here") except Exception, e: self.assertEqual('could not create temporary file for content_reference -> (some error)', str(e))