Commit 5a1733e6 authored by Wout De Nolf's avatar Wout De Nolf
Browse files

pytest manages log level and handlers

parent 696397a7
import sys
import logging
import pytest
from pypushflow import persistence
from . import test_ppf_actors
# loggers = [logging.getLogger("pypushflow"), logging.getLogger("ewoksppf")]
loggers = [logging.getLogger("ewoksppf")]
test_ppf_actors.SLEEP_TIME = 0
@pytest.fixture(scope="session")
def ppf_logging():
stdouthandler = logging.StreamHandler(sys.stdout)
levels = []
for logger in loggers:
levels.append(logger.getEffectiveLevel())
logger.setLevel(logging.DEBUG)
logger.addHandler(stdouthandler)
def ppf_log_config():
DEFAULT_DB_TYPE = persistence.DEFAULT_DB_TYPE
persistence.DEFAULT_DB_TYPE = "memory"
yield
persistence.DEFAULT_DB_TYPE = DEFAULT_DB_TYPE
for level, logger in zip(levels, loggers):
logger.setLevel(level)
logger.removeHandler(stdouthandler)
......@@ -14,7 +14,7 @@ from ewokscore.tests.utils import assert_workflow_merged_result
@pytest.mark.parametrize(
"graph_name,persist", itertools.product(graph_names(), (True, False))
)
def test_execute_graph(graph_name, persist, ppf_logging, tmpdir):
def test_execute_graph(graph_name, persist, ppf_log_config, tmpdir):
g, expected = get_graph(graph_name)
if persist:
varinfo = {"root_uri": str(tmpdir)}
......
......@@ -58,7 +58,7 @@ def workflow():
@pytest.mark.skip("TODO")
def test_ppf_end(ppf_logging):
def test_ppf_end(ppf_log_config):
graph, expected = workflow()
result = execute_graph(graph)
for k, v in expected.items():
......
......@@ -27,7 +27,7 @@ def workflow1():
return graph, expected_results
def test_workflow1(ppf_logging, tmpdir):
def test_workflow1(ppf_log_config, tmpdir):
varinfo = {"root_uri": str(tmpdir)}
graph, expected = workflow1()
execute_graph(graph, varinfo=varinfo)
......
......@@ -53,7 +53,7 @@ def workflow10(inputs):
"limit,persistent",
itertools.product([10], [True, False]),
)
def test_workflow10(limit, persistent, ppf_logging, tmpdir):
def test_workflow10(limit, persistent, ppf_log_config, tmpdir):
if persistent:
varinfo = {"root_uri": str(tmpdir)}
else:
......
......@@ -129,7 +129,7 @@ def workflow11():
return graph, expected_results
def test_workflow11(ppf_logging, tmpdir):
def test_workflow11(ppf_log_config, tmpdir):
varinfo = {"root_uri": str(tmpdir)}
graph, expected = workflow11()
execute_graph(graph, varinfo=varinfo)
......
......@@ -91,7 +91,7 @@ def workflow12(startvalue, withsubmodel_startvalue):
@pytest.mark.parametrize("startvalue", [0, 1])
def test_workflow12(startvalue, ppf_logging, tmpdir):
def test_workflow12(startvalue, ppf_log_config, tmpdir):
withsubmodel_startvalue = 1
varinfo = {"root_uri": str(tmpdir)}
graph, expected = workflow12(startvalue, withsubmodel_startvalue)
......
......@@ -88,7 +88,7 @@ def workflow13(startvalue, withlastnode_startvalue):
@pytest.mark.parametrize("startvalue", [0, 1])
def test_workflow13(startvalue, ppf_logging, tmpdir):
def test_workflow13(startvalue, ppf_log_config, tmpdir):
withlastnode_startvalue = 1
varinfo = {"root_uri": str(tmpdir)}
graph, expected = workflow13(startvalue, withlastnode_startvalue)
......
......@@ -115,7 +115,7 @@ def workflow14():
return graph, expected_results
def test_workflow14(ppf_logging, tmpdir):
def test_workflow14(ppf_log_config, tmpdir):
varinfo = {"root_uri": str(tmpdir)}
graph, expected = workflow14()
execute_graph(graph, varinfo=varinfo)
......
......@@ -102,7 +102,7 @@ def workflow15():
return graph, expected_results
def test_workflow15(ppf_logging, tmpdir):
def test_workflow15(ppf_log_config, tmpdir):
"""Test connecting nodes from submodels directly"""
varinfo = {"root_uri": str(tmpdir)}
graph, expected = workflow15()
......
......@@ -131,7 +131,7 @@ def workflow16():
return graph, expected_results
def test_workflow16(ppf_logging, tmpdir):
def test_workflow16(ppf_log_config, tmpdir):
"""Test connecting nodes from sub-submodels to the top model"""
varinfo = {"root_uri": str(tmpdir)}
graph, expected = workflow16()
......
......@@ -47,7 +47,7 @@ def workflow17(doloop=True):
@pytest.mark.parametrize("doloop", [True, False])
def test_workflow17(doloop, ppf_logging):
def test_workflow17(doloop, ppf_log_config):
"""Test 2 unconditional upstream tasks, one coming from a feedback loop"""
graph, expected = workflow17(doloop=doloop)
result = execute_graph(graph)
......
......@@ -52,7 +52,7 @@ def workflow18(dotask4=True):
@pytest.mark.parametrize("dotask4", [True, False])
def test_workflow18(dotask4, ppf_logging, tmpdir):
def test_workflow18(dotask4, ppf_log_config, tmpdir):
"""Test conditional links"""
varinfo = {"root_uri": str(tmpdir)}
graph, expected = workflow18(dotask4=dotask4)
......
......@@ -68,7 +68,7 @@ def workflow19():
return graph, expected_results
def test_workflow19(ppf_logging, tmpdir):
def test_workflow19(ppf_log_config, tmpdir):
"""Test 2 unconditional upstream tasks, one coming from a feedback loop"""
graph, expected = workflow19()
result = execute_graph(graph)
......
......@@ -26,7 +26,7 @@ def workflow2():
return graph, expected_results
def test_workflow2(ppf_logging, tmpdir):
def test_workflow2(ppf_log_config, tmpdir):
varinfo = {"root_uri": str(tmpdir)}
graph, expected = workflow2()
result = execute_graph(graph, varinfo=varinfo, raise_on_error=False)
......
......@@ -20,7 +20,7 @@ def workflow20():
@pytest.mark.parametrize("persist", [True, False])
def test_workflow20(persist, ppf_logging, tmpdir):
def test_workflow20(persist, ppf_log_config, tmpdir):
if persist:
varinfo = {"root_uri": str(tmpdir)}
else:
......
......@@ -73,7 +73,7 @@ def workflow3():
return graph, expected_results
def test_workflow3(ppf_logging, tmpdir):
def test_workflow3(ppf_log_config, tmpdir):
varinfo = {"root_uri": str(tmpdir)}
graph, expected = workflow3()
execute_graph(graph, varinfo=varinfo)
......
......@@ -82,7 +82,7 @@ def workflow6():
return graph, expected_results
def test_workflow6(ppf_logging, tmpdir):
def test_workflow6(ppf_log_config, tmpdir):
varinfo = {"root_uri": str(tmpdir)}
graph, expected = workflow6()
execute_graph(graph, varinfo=varinfo)
......
......@@ -68,7 +68,7 @@ def workflow7():
return graph, expected_results
def test_workflow7(ppf_logging, tmpdir):
def test_workflow7(ppf_log_config, tmpdir):
varinfo = {"root_uri": str(tmpdir)}
graph, expected = workflow7()
execute_graph(graph, varinfo=varinfo)
......
......@@ -68,7 +68,7 @@ def workflow8():
return graph, expected_results
def test_workflow8(ppf_logging, tmpdir):
def test_workflow8(ppf_log_config, tmpdir):
varinfo = {"root_uri": str(tmpdir)}
graph, expected = workflow8()
execute_graph(graph, varinfo=varinfo)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment