Skip to content

Commit 8f7408d

Browse files
committed
Use package-level logger for test-related warnings.
Do not use root logger for output from diffpy.srreal.tests.
1 parent 7d62030 commit 8f7408d

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

diffpy/srreal/tests/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
"""
1818

1919

20+
# create logger instance for the tests subpackage
21+
import logging
22+
23+
logging.basicConfig()
24+
logger = logging.getLogger(__name__)
25+
del logging
26+
2027

2128
def testsuite():
2229
'''Build a unit tests suite for the diffpy.srreal package.

diffpy/srreal/tests/testutils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
"""
1111

1212

13-
import logging
14-
1513
from diffpy.srreal.structureconverters import convertObjCrystCrystal
14+
from diffpy.srreal.tests import logger
1615

1716
# class TestCaseObjCrystOptional
1817

@@ -22,10 +21,10 @@
2221
convertObjCrystCrystal(pyobjcryst.crystal.Crystal())
2322
except ImportError:
2423
TestCaseObjCrystOptional = object
25-
logging.warning('Cannot import pyobjcryst, pyobjcryst tests skipped.')
24+
logger.warning('Cannot import pyobjcryst, pyobjcryst tests skipped.')
2625
except TypeError:
2726
TestCaseObjCrystOptional = object
28-
logging.warning('Compiled without ObjCryst, pyobjcryst tests skipped.')
27+
logger.warning('Compiled without ObjCryst, pyobjcryst tests skipped.')
2928

3029
# class TestCasePeriodictableOptional
3130

@@ -34,7 +33,7 @@
3433
from unittest import TestCase as TestCasePeriodictableOptional
3534
except ImportError:
3635
TestCasePeriodictableOptional = object
37-
logging.warning('Cannot import periodictable, periodictable tests skipped.')
36+
logger.warning('Cannot import periodictable, periodictable tests skipped.')
3837

3938
# helper functions
4039

0 commit comments

Comments
 (0)