import miniflask  # noqa: E402


def test_global_setup(capsys):
    mf = miniflask.init(
        ".modules",
        debug=True
    )

    mf.load("globalvar")
    mf.parse_args([
    ])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == """
globalvar: 1
""".lstrip()


def test_global_cli_override(capsys):
    mf = miniflask.init(
        ".modules",
        debug=True
    )

    mf.load("globalvar")
    mf.parse_args([
        "--globalvar", "42",
    ])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == """
globalvar: 42
""".lstrip()


def test_override(capsys):
    mf = miniflask.init(
        ".modules",
        debug=True
    )

    mf.load(["globalvar", "globalvar_override"])
    mf.parse_args([])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == """
globalvar: 11
""".lstrip()


def test_override_cli(capsys):
    mf = miniflask.init(
        ".modules",
        debug=True
    )

    mf.load(["globalvar", "globalvar_override"])
    mf.parse_args([
        "--globalvar", "111",
    ])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == """
globalvar: 111
""".lstrip()

4f35b007cd2c954480104a16b54c7e8dfa2773da
<mask token>


def test_global_setup(capsys):
    mf = miniflask.init('.modules', debug=True)
    mf.load('globalvar')
    mf.parse_args([])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == '\nglobalvar: 1\n'.lstrip()


<mask token>


def test_override_cli(capsys):
    mf = miniflask.init('.modules', debug=True)
    mf.load(['globalvar', 'globalvar_override'])
    mf.parse_args(['--globalvar', '111'])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == '\nglobalvar: 111\n'.lstrip()

<mask token>


def test_global_setup(capsys):
    mf = miniflask.init('.modules', debug=True)
    mf.load('globalvar')
    mf.parse_args([])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == '\nglobalvar: 1\n'.lstrip()


<mask token>


def test_override(capsys):
    mf = miniflask.init('.modules', debug=True)
    mf.load(['globalvar', 'globalvar_override'])
    mf.parse_args([])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == '\nglobalvar: 11\n'.lstrip()


def test_override_cli(capsys):
    mf = miniflask.init('.modules', debug=True)
    mf.load(['globalvar', 'globalvar_override'])
    mf.parse_args(['--globalvar', '111'])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == '\nglobalvar: 111\n'.lstrip()

<mask token>


def test_global_setup(capsys):
    mf = miniflask.init('.modules', debug=True)
    mf.load('globalvar')
    mf.parse_args([])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == '\nglobalvar: 1\n'.lstrip()


def test_global_cli_override(capsys):
    mf = miniflask.init('.modules', debug=True)
    mf.load('globalvar')
    mf.parse_args(['--globalvar', '42'])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == '\nglobalvar: 42\n'.lstrip()


def test_override(capsys):
    mf = miniflask.init('.modules', debug=True)
    mf.load(['globalvar', 'globalvar_override'])
    mf.parse_args([])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == '\nglobalvar: 11\n'.lstrip()


def test_override_cli(capsys):
    mf = miniflask.init('.modules', debug=True)
    mf.load(['globalvar', 'globalvar_override'])
    mf.parse_args(['--globalvar', '111'])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == '\nglobalvar: 111\n'.lstrip()

import miniflask


def test_global_setup(capsys):
    mf = miniflask.init('.modules', debug=True)
    mf.load('globalvar')
    mf.parse_args([])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == '\nglobalvar: 1\n'.lstrip()


def test_global_cli_override(capsys):
    mf = miniflask.init('.modules', debug=True)
    mf.load('globalvar')
    mf.parse_args(['--globalvar', '42'])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == '\nglobalvar: 42\n'.lstrip()


def test_override(capsys):
    mf = miniflask.init('.modules', debug=True)
    mf.load(['globalvar', 'globalvar_override'])
    mf.parse_args([])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == '\nglobalvar: 11\n'.lstrip()


def test_override_cli(capsys):
    mf = miniflask.init('.modules', debug=True)
    mf.load(['globalvar', 'globalvar_override'])
    mf.parse_args(['--globalvar', '111'])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == '\nglobalvar: 111\n'.lstrip()

import miniflask  # noqa: E402


def test_global_setup(capsys):
    mf = miniflask.init(
        ".modules",
        debug=True
    )

    mf.load("globalvar")
    mf.parse_args([
    ])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == """
globalvar: 1
""".lstrip()


def test_global_cli_override(capsys):
    mf = miniflask.init(
        ".modules",
        debug=True
    )

    mf.load("globalvar")
    mf.parse_args([
        "--globalvar", "42",
    ])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == """
globalvar: 42
""".lstrip()


def test_override(capsys):
    mf = miniflask.init(
        ".modules",
        debug=True
    )

    mf.load(["globalvar", "globalvar_override"])
    mf.parse_args([])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == """
globalvar: 11
""".lstrip()


def test_override_cli(capsys):
    mf = miniflask.init(
        ".modules",
        debug=True
    )

    mf.load(["globalvar", "globalvar_override"])
    mf.parse_args([
        "--globalvar", "111",
    ])
    captured = capsys.readouterr()
    mf.event.print_all()
    captured = capsys.readouterr()
    assert captured.out == """
globalvar: 111
""".lstrip()
