示例#1
0
def test_two_arg_reversed_order(parser, capfd):
    args = parser.parse_args(['-l', '187', '-w', '80'])
    handle_args(args)
    output = capfd.readouterr()[0]
    assert "Your BMI is: 22.88" in output
示例#2
0
def test_no_args_exits(parser):
    # parser.parse_args should raise the exception but in case
    # you raised it explicitly further down the stack let's check
    # if handle_args raises it (same applies to next test)
    with pytest.raises(SystemExit):
        handle_args()
示例#3
0
def test_one_arg_exits(parser):
    with pytest.raises(SystemExit):
        args = parser.parse_args(['-w', '80'])
        handle_args(args)
示例#4
0
def test_only_length_exits(parser):
    with pytest.raises(SystemExit):
        args = parser.parse_args(['-l', '187'])
        handle_args(args)
示例#5
0
def test_different_args(parser, capfd):
    args = parser.parse_args(['-l', '200', '-w', '100'])
    handle_args(args)
    output = capfd.readouterr()[0]
    assert "Your BMI is: 25.0" in output
示例#6
0
def test_help_flag_exits(parser):
    with pytest.raises(SystemExit):
        args = parser.parse_args(['-h'])
        handle_args(args)
示例#7
0
def test_different_args(parser, capfd):
    args = parser.parse_args(["-l", "200", "-w", "100"])
    handle_args(args)
    output = capfd.readouterr()[0]
    assert "Your BMI is: 25.0" in output
示例#8
0
def test_two_arg_reversed_order(parser, capfd):
    args = parser.parse_args(["-l", "187", "-w", "80"])
    handle_args(args)
    output = capfd.readouterr()[0]
    assert "Your BMI is: 22.88" in output
示例#9
0
def test_only_length_exits(parser):
    with pytest.raises(SystemExit):
        args = parser.parse_args(["-l", "187"])
        handle_args(args)
示例#10
0
def test_only_width_exits(parser):
    with pytest.raises(SystemExit):
        args = parser.parse_args(["-w", "80"])
        handle_args(args)