def test_more_logging_tests(caplog): """Testing on the logging levels, see that ENV variable will override the basiclogger setting. """ os.environ["FMU_LOGGING_LEVEL"] = "INFO" fmumore = etc.Interaction() # another instance locallogger = fmumore.basiclogger(__name__, level="WARNING") locallogger.debug("Display debug") assert caplog.text == "" # shall be empty locallogger.info("Display info") assert "info" in caplog.text # INFO shall be shown, overrided by ENV! locallogger.warning("Display warning") assert "warning" in caplog.text locallogger.critical("Display critical") assert "critical" in caplog.text
# -*- coding: utf-8 -*- """Addon to configparser.py. Focus on IPL handling""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from copy import deepcopy from collections import OrderedDict import os import datetime from fmu.config import etc XFMU = etc.Interaction() logger = XFMU.functionlogger(__name__) # pylint: disable=protected-access # pylint: disable=too-many-branches class ConfigError(ValueError): """Exception used for config error, derived from ValueError""" def to_ipl(self, rootname="global_variables", destination=None, template=None, tool="rms"): """Export the config as a global variables IPL and/or template
# for ordered dicts! from collections import OrderedDict, Counter try: from fmu.config._theversion import version as theversion except ImportError: theversion = "0.0.0" from fmu.config import oyaml as yaml from fmu.config._loader import FmuLoader, ConstructorError from fmu.config import etc from fmu.config import _configparserfmu_ipl xfmu = etc.Interaction() logger = xfmu.functionlogger(__name__) class ConfigParserFMU(object): """Class for parsing global config files for FMU.""" def __init__(self): self._config = {} self._yamlfile = None self._runsilent = True logger.debug("Ran __init__") @property def config(self): """Get the current config as a Python dictionary (read only).""" return self._config
# -*- coding: utf-8 -*- """Testing the classes/functions in in the etc module.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import pytest from fmu.config import etc fmux = etc.Interaction() logger = fmux.basiclogger(__name__) logger.info("Running tests...") # always this statement if not fmux.testsetup(): raise SystemExit() def test_info_logger_plain(): """Test basic logger behaviour plain, will capture output to stdin""" logger.info("This is a test") # no assert is intended @pytest.fixture(name="mylogger") def fixture_mylogger(): """Add logger"""