Skip to content

Commit

Permalink
tests: spawn a logger instance for each test
Browse files Browse the repository at this point in the history
(cherry picked from commit 1d005ec)
  • Loading branch information
fvennetier committed Jun 21, 2022
1 parent de7d00a commit e56091c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 6 additions & 3 deletions tests/functional/content/test_plain.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (C) 2015-2020 OpenIO SAS, as part of OpenIO SDS
# Copyright (C) 2022 OVH SAS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -45,9 +46,11 @@ def setUp(self):
self.account = self.conf['account']
self.chunk_size = self.conf['chunk_size']
self.gridconf = {"namespace": self.namespace}
self.content_factory = ContentFactory(self.gridconf)
self.container_client = ContainerClient(self.gridconf)
self.blob_client = BlobClient(self.conf)
self.content_factory = ContentFactory(
self.gridconf, logger=self.logger)
self.container_client = ContainerClient(
self.gridconf, logger=self.logger)
self.blob_client = BlobClient(self.conf, logger=self.logger)
self.container_name = "TestPlainContent-%f" % time.time()
self.container_client.container_create(account=self.account,
reference=self.container_name)
Expand Down
10 changes: 9 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2015-2019 OpenIO SAS, as part of OpenIO SDS
# Copyright (C) 2022 OVH SAS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -230,6 +231,7 @@ def setUp(self):
self._beanstalkd0 = None
self._conscience = None
self._http_pool = None
self._logger = None
self._storage_api = None
# Namespace configuration, from "sds.conf"
self._ns_conf = None
Expand Down Expand Up @@ -290,6 +292,12 @@ def storage(self):
pool_manager=self.http_pool)
return self._storage_api

@property
def logger(self):
if not self._logger:
self._logger = logging.getLogger('test')
return self._logger

@property
def ns_conf(self):
"""
Expand Down Expand Up @@ -421,7 +429,7 @@ def json_loads(cls, data):
try:
return jsonlib.loads(data)
except ValueError:
logging.info("Unparseable data: %s", str(data))
logging.info("Unparsable data: %s", str(data))
raise


Expand Down

0 comments on commit e56091c

Please sign in to comment.