for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
# coding: utf8
# Copyright 2013-2015 Vincent Jacques <[email protected]>
from __future__ import division, absolute_import, print_function
import pickle
import unittest
import sys
import tempfile
from ActionTree import *
from . import *
class Unpicklable(object):
def __reduce__(self):
raise pickle.PicklingError
unpicklable = Unpicklable()
class UnpicklableReturnValue(Action):
def do_execute(self):
return unpicklable
class UnpicklableException(Action):
raise Exception(unpicklable)
class PicklabilityTestCase(ActionTreeTestCase):
def test_action(self):
with self.assertRaises(pickle.PicklingError):
execute(self._action(unpicklable))
def test_return_value(self):
# DO NOT use self._action(return_value=unpicklable)
# because the *Action* would be unpicklable and we're testing what happens
# when the *return value* is unpicklable
execute(UnpicklableReturnValue("x"))
def test_exception(self):
# when the *exception* is unpicklable
execute(UnpicklableException("x"))