コード例 #1
0
 def test_load_service_by_str(self):
     self.assertIsInstance(
         utils.load_service(Service.__module__ + '.Service'), Service_test)
コード例 #2
0
 def test_load_service_by_class(self):
     self.assertIsInstance(utils.load_service(Service), Service_test)
コード例 #3
0
    def test_load_service_unregistered(self):
        with self.assertRaises(KeyError), self.assertLogs(
                utils.__name__) as log:
            utils.load_service(__name__)

        self.assertIn(f'{__name__} is not registered', str(log.output))
コード例 #4
0
 def test_load_service_by_instance(self):
     service = Service()
     self.assertIs(utils.load_service(service), service)
コード例 #5
0
 def test_load_service_by_str_using_default_implementation(self):
     self.assertIsInstance(
         utils.load_service(Service.__module__ + '.Service2'), Service)