Exemple #1
0
    def test_location_registry_empty(self):
        registry = TargetRegistry()
        with self.assertRaises(LocationNotSupported) as exception_context:
            registry.get_solver(None, None)

        self.assertEqual(exception_context.exception.supported, [])
        self.assertEqual(
            str(exception_context.exception),
            "Location None is not supported for None. Supported these: []",
        )
Exemple #2
0
    def test_register_location_report_existing(self):
        def solver(wrapper, location):
            return 1

        registry = TargetRegistry()
        registry.register_location(target_class=float,
                                   locator_class=str,
                                   solver=solver)

        with self.assertRaises(LocationNotSupported) as exception_context:
            registry.get_solver(float, None)

        self.assertEqual(exception_context.exception.supported, [str])
Exemple #3
0
    def test_register_location(self):
        def solver(wrapper, location):
            return 1

        registry = TargetRegistry()
        registry.register_location(target_class=float,
                                   locator_class=str,
                                   solver=solver)

        self.assertIs(registry.get_solver(float, str), solver)