예제 #1
0
def test_filtered_warning():
    """ Sink doesn't warn about potentially erroneous usage.
    """
    warnings.filterwarnings("ignore", category=SuspiciousUsageWarning)
    look_out = network.Bus()
    with warnings.catch_warnings(record=True) as w:
        network.Sink(outputs={look_out: "A typo!"})
        ok_(len(w) == 0)
예제 #2
0
def test_that_the_solph_source_warnings_actually_get_raised():
    """ Source doesn't warn about potentially erroneous usage.
    """
    look_out = network.Bus()
    msg = "`Source` 'solph_sink' constructed without `outputs`."
    with warnings.catch_warnings(record=True) as w:
        solph.Source(label="solph_sink", inputs={look_out: "A typo!"})
        ok_(len(w) == 1)
        eq_(msg, str(w[-1].message))
예제 #3
0
def test_that_the_transformer_warnings_actually_get_raised():
    """ Transformer doesn't warn about potentially erroneous usage.
    """
    look_out = network.Bus()
    msg = "`Transformer` 'no input' constructed without `inputs`."
    with warnings.catch_warnings(record=True) as w:
        solph.Transformer(label='no input', outputs={look_out: "No inputs!"})
        ok_(len(w) == 1)
        eq_(msg, str(w[-1].message))
    msg = "`Transformer` 'no output' constructed without `outputs`."
    with warnings.catch_warnings(record=True) as w:
        solph.Transformer(label='no output', inputs={look_out: "No outputs!"})
        ok_(len(w) == 1)
        eq_(msg, str(w[-1].message))