Пример #1
0
    def test_dual_transformer_regression_test(self):
        """DualTransformer has failed when there were multiple DualTransformers.
        It has also failed when DualTransformer was not the outermost
        transformer or when other transformers were between multiple
        DualTransformers."""
        player = InterspersedDualTransformersNamePrefixAbsent()
        self.assert_orignal_equals_pickled(player)

        player = InterspersedDualTransformersNamePrefixPresent()
        self.assert_orignal_equals_pickled(player)

        player_class = axl.WinStayLoseShift
        player_class = st.DualTransformer()(player_class)
        player_class = st.InitialTransformer((C, D))(player_class)
        player_class = st.DualTransformer()(player_class)
        player_class = st.TrackHistoryTransformer()(player_class)

        interspersed_dual_transformers = player_class()

        self.assert_orignal_equals_pickled(interspersed_dual_transformers)
Пример #2
0
    Retaliation,
    RetaliateUntilApology,
    TrackHistory,
    Dual,
    Identity,
]

transformer_instances = [
    st.ApologyTransformer([D], [C]),
    st.DeadlockBreakingTransformer(),
    st.DualTransformer(),
    st.FlipTransformer(),
    st.FinalTransformer((D, D)),
    st.ForgiverTransformer(0.2),
    st.GrudgeTransformer(3),
    st.InitialTransformer((C, D)),
    st.JossAnnTransformer((0.2, 0.6)),
    st.MixedTransformer(probability, strategies),
    st.NiceTransformer(),
    st.NoisyTransformer(0.2),
    st.RetaliationTransformer(3),
    st.RetaliateUntilApologyTransformer(),
    st.TrackHistoryTransformer(),
    st.IdentityTransformer(),
]


class TestPickle(unittest.TestCase):
    def assert_equals_instance_from_pickling(self, original_instance):
        copy = pickle.loads(pickle.dumps(original_instance))
        self.assertEqual(copy, original_instance)