Esempio n. 1
0
    def test_advice_builder_prelude(self):
        builder = AdviceBuilder()
        builder.add_prelude(Target.increment_count, increment_count)
        builder.apply()

        target = Target()
        target.increment_count()
        self.assertEqual(
            target.count, 1 + 1
        )  # Should have incremented after being initially incremented by a prelude.
Esempio n. 2
0
    def test_advice_builder_multiple_preludes(self):
        builder = AdviceBuilder()
        builder.add_prelude(Target.increment_count, increment_count)
        builder.add_prelude(Target.increment_count, increment_count)
        builder.apply()

        target = Target()
        target.increment_count()
        self.assertEqual(
            target.count, 1 + 1 + 1
        )  # Should have incremented after being incremented twice by two preludes.