# Path: ciao_contrib/logger_wrapper.py
# def initialize_logger(name, verbose=0, out=sys.stdout):
#     """Create a logger with the name cxc.ciao.contrib.<name>.
# 
#     If there is no handler already set up, then add one
#     (to cxc.ciao.contrib) that logs all
#     messages with a format of just the message (i.e. just
#     '%(message)s').
# 
#     The name can include "." characters.
# 
#     Returns an instance of the logger. Use the verbose0()
#     ... verbose5() methods to display a message if the verbosity
#     of the logger is >= 0 ... 5.
# 
#     The verbose field is used to set or get the verbosity
#     level of the logger. This routine sets the level to
#     the given verbose value (-1 means not set).
# 
#     The out option controls where the messages are logged to.
#     The default value is sys.stdout.
# 
#     Note: if a handler already exists for this logger
#     then none is added.
# 
#     """
# 
#     plogger = logging.getLogger(lhead)
# 
#     if plogger.handlers == []:
#         hdlr = logging.StreamHandler(stream=out)
#         # hdlr.setFormatter(logging.Formatter("%(message)s"))
#         plogger.addHandler(hdlr)
# 
#     logger = get_logger(name)
#     set_verbosity(verbose)
#     return logger
# 
# def set_verbosity(verbose=1):
#     """Sets the verbosity of the contrib logging
#     level cxc.ciao.contrib. This is the level in the hierarchy
#     which "general users" should use for logging.
# 
#     It does not check the hierarchy for whether 'parent'
#     or 'child' elements have a different verbosity and
#     so should also be changed.
# 
#     A value of -1 means "unset".
#     """
# 
#     _check_verbose(verbose)
#     logging.getLogger(lhead).verbose = verbose


import os
import pathlib
import pytest
import ciao_contrib.runtool as rt
from ciao_contrib.logger_wrapper import initialize_logger, set_verbosity
"""Basic tests of the runtool interface"""





ALL_TOOLS = rt.list_tools()
SPECIAL_TOOLS = ['axbary', 'dmgti', 'evalpos', 'fullgarf',
                 'mean_energy_map', 'pileup_map', 'tgdetect',
                 'wavdetect']
PAR_TOOLS = ['ardlib', 'colors', 'dax', 'geom', 'imagej_lut', 'lut', 'ximage_lut']

STANDARD_TOOLS = list(set(ALL_TOOLS) - set(SPECIAL_TOOLS) - set(PAR_TOOLS))


# The current tests assume a conda-installed CIAO environment
#
ASCDS_INSTALL = pathlib.Path(os.getenv('ASCDS_INSTALL'))


initialize_logger('test_runtool')
set_verbosity(0)


@pytest.fixture
def verbose5():


# Path: ciao_contrib/logger_wrapper.py
# def initialize_logger(name, verbose=0, out=sys.stdout):
#     """Create a logger with the name cxc.ciao.contrib.<name>.
# 
#     If there is no handler already set up, then add one
#     (to cxc.ciao.contrib) that logs all
#     messages with a format of just the message (i.e. just
#     '%(message)s').
# 
#     The name can include "." characters.
# 
#     Returns an instance of the logger. Use the verbose0()
#     ... verbose5() methods to display a message if the verbosity
#     of the logger is >= 0 ... 5.
# 
#     The verbose field is used to set or get the verbosity
#     level of the logger. This routine sets the level to
#     the given verbose value (-1 means not set).
# 
#     The out option controls where the messages are logged to.
#     The default value is sys.stdout.
# 
#     Note: if a handler already exists for this logger
#     then none is added.
# 
#     """
# 
#     plogger = logging.getLogger(lhead)
# 
#     if plogger.handlers == []:
#         hdlr = logging.StreamHandler(stream=out)
#         # hdlr.setFormatter(logging.Formatter("%(message)s"))
#         plogger.addHandler(hdlr)
# 
#     logger = get_logger(name)
#     set_verbosity(verbose)
#     return logger
# 
# def set_verbosity(verbose=1):
#     """Sets the verbosity of the contrib logging
#     level cxc.ciao.contrib. This is the level in the hierarchy
#     which "general users" should use for logging.
# 
#     It does not check the hierarchy for whether 'parent'
#     or 'child' elements have a different verbosity and
#     so should also be changed.
# 
#     A value of -1 means "unset".
#     """
# 
#     _check_verbose(verbose)
#     logging.getLogger(lhead).verbose = verbose


# Path: tests/test_runtool.py
import os
import pathlib
import pytest
import ciao_contrib.runtool as rt
from ciao_contrib.logger_wrapper import initialize_logger, set_verbosity

"""Basic tests of the runtool interface"""





ALL_TOOLS = rt.list_tools()
SPECIAL_TOOLS = ['axbary', 'dmgti', 'evalpos', 'fullgarf',
                 'mean_energy_map', 'pileup_map', 'tgdetect',
                 'wavdetect']
PAR_TOOLS = ['ardlib', 'colors', 'dax', 'geom', 'imagej_lut', 'lut', 'ximage_lut']

STANDARD_TOOLS = list(set(ALL_TOOLS) - set(SPECIAL_TOOLS) - set(PAR_TOOLS))


# The current tests assume a conda-installed CIAO environment
#
ASCDS_INSTALL = pathlib.Path(os.getenv('ASCDS_INSTALL'))


initialize_logger('test_runtool')
set_verbosity(0)


@pytest.fixture
def verbose5():


    set_verbosity(5)