Ejemplo n.º 1
0
    def test_to_interface_check(self):
        with self.assertRaises(ValueError):  # to_interface is an interface
            pure_interface.register_adapter(TalkerToSpeaker3, Talker, Talker)

        with self.assertRaises(ValueError):  # to_interface is not concrete
            pure_interface.register_adapter(TalkerToSpeaker3, Talker,
                                            TalkerToSpeaker)
Ejemplo n.º 2
0
    def test_from_type_check(self):
        with self.assertRaises(ValueError):  # must be callable
            pure_interface.register_adapter(TalkerToSpeaker3, 6, ISpeaker)

        with self.assertRaises(ValueError):  # already adapted
            pure_interface.register_adapter(TalkerToSpeaker, Talker, ISpeaker)
Ejemplo n.º 3
0
 def test_adapter_check(self):
     with self.assertRaises(ValueError):
         pure_interface.register_adapter(5, Talker, ISpeaker)
Ejemplo n.º 4
0
 def test_adapter_call_check(self):
     pure_interface.register_adapter(bad_adapter, Talker4, ISpeaker)
     talker = Talker4()
     with self.assertRaises(ValueError):
         ISpeaker.adapt(talker, interface_only=False)