Completed
Push — dev ( 68ddc7...49e927 )
by Patrik
58s queued 48s
created

tests.regression_tests.test_wrong_logging_level()   A

Complexity

Conditions 2

Size

Total Lines 9
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 9
rs 9.95
c 0
b 0
f 0
cc 2
nop 0
1
# -*- coding: utf-8 -
2
3
"""Regression tests.
4
5
This file is part of project oemof (github.com/oemof/oemof). It's copyrighted
6
by the contributors recorded in the version control history of the file,
7
available from its original location oemof/tests/regression_tests.py
8
9
SPDX-License-Identifier: MIT
10
"""
11
12
import logging
13
14
import pandas as pd
15
import pytest
16
17
from oemof import solph
18
from oemof import tools
19
from oemof.solph._models import LoggingError
20
21
22
def test_version_metadata():
23
    assert solph.__version__
24
25
26
def test_wrong_logging_level():
27
    datetimeindex = pd.date_range("1/1/2012", periods=12, freq="h")
28
    es = solph.EnergySystem(timeindex=datetimeindex, infer_last_interval=True)
29
    tools.logger.define_logging()
30
    my_logger = logging.getLogger()
31
    my_logger.setLevel("DEBUG")
32
    with pytest.raises(LoggingError, match="The root logger level is 'DEBUG'"):
33
        solph.Model(es)
34
    my_logger.setLevel("WARNING")
35