Esempio n. 1
0
    def test_post_rollback_funcs_error(self):
        def func():
            raise ValueError()

        with self.assertRaises(RuntimeError):
            with TRN:
                TRN.add("SELECT 42")
                TRN.add_post_rollback_func(func)
                TRN.rollback()
Esempio n. 2
0
    def test_post_rollback_funcs(self):
        fd, fp = mkstemp()
        close(fd)
        self._files_to_remove.append(fp)

        def func(fp):
            with open(fp, "w") as f:
                f.write("\n")

        with TRN:
            TRN.add("SELECT 42")
            TRN.add_post_rollback_func(func, fp)
            TRN.rollback()

        self.assertTrue(exists(fp))