Fetch the repository succeeded.
This action will force synchronization from 首都经济贸易大学-高强/e0501-builtins, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
import pytest
import e02_list_quiz as q
@pytest.mark.parametrize(
"lst, res",
[
[[2, 3, -1, 5, 0, 4], [4, 9, 25, 16]],
[[1, -1, 2, -2, 3, -3], [1, 4, 9]],
[[-2, -3, -1], []],
],
)
def test_001(lst, res):
assert q.f001(lst) == res
@pytest.mark.parametrize(
"lst, res",
[
[["/home", "/home/qiang", "/etc"], 4],
[["https://www.cueb.edu.cn", "www.baidu.com"], 2],
[["pystudy", "exercise"], 0],
],
)
def test_002(lst, res):
assert q.f002(lst) == res
@pytest.mark.parametrize(
"n, output",
[
[3, "L\nLL\nLLL"],
[5, "L\nLL\nLLL\nLLLL\nLLLLL"],
],
)
def test_003(n, output, capsys):
q.f003(n)
out, err = capsys.readouterr()
assert out == output + "\n"
@pytest.mark.parametrize(
"lst, item, expected",
[
[[3, 1, 2], 0, [3, 1, 2, 0]],
[["d", "f", "b"], "a", ["d", "f", "b", "a"]],
],
)
def test_004(lst, item, expected):
res = q.f004(lst, item)
assert res is None
assert lst == expected
@pytest.mark.parametrize(
"lst, item, expected",
[
[[3, 1, 2], 0, [3, 1, 2, 0]],
[["d", "f", "b"], "a", ["d", "f", "b", "a"]],
],
)
def test_005(lst, item, expected):
lst_bak = lst.copy()
res = q.f005(lst, item)
assert lst == lst_bak
assert res is not lst
assert res == expected
@pytest.mark.parametrize(
"lst, args, expected",
[
[[3, 1, 2], (5, 0), [3, 1, 2, 5, 0]],
[["d", "f", "b"], ("a", "h", "c"), ["d", "f", "b", "a", "h", "c"]],
],
)
def test_006(lst, args, expected):
res = q.f006(lst, *args)
assert res is None
assert lst == expected
@pytest.mark.parametrize(
"lst, item, expected",
[
[[3, 1, 2], 0, [3, 1, 2, 0]],
[["d", "f", "b"], "a", ["d", "f", "b", "a"]],
],
)
def test_007(lst, item, expected):
lst_bak = lst.copy()
res = q.f007(lst, item)
assert lst == lst_bak
assert res is not lst
assert res == expected
@pytest.mark.parametrize(
"lst, n, expected",
[
[[3, 1, 2, 5, 6], 2, [2, 5, 6]],
[["d", "f", "b", "a", "h", "c"], 4, ["h", "c"]],
],
)
def test_008(lst, n, expected):
lst_bak = lst.copy()
res = q.f008(lst, n)
assert lst == lst_bak
assert res is not lst
assert res == expected
@pytest.mark.parametrize(
"lst, n, expected",
[
[[3, 1, 2, 5, 6], 2, [3, 1, 5, 6]],
[["d", "f", "b", "a", "h", "c"], 1, ["d", "c"]],
],
)
def test_009(lst, n, expected):
lst_bak = lst.copy()
res = q.f009(lst, n)
assert lst == lst_bak
assert res is not lst
assert res == expected
@pytest.mark.parametrize(
"lst, n, expected",
[
[[3, 1, 2, 5, 6], 2, [3, 1, 2]],
[["d", "f", "b", "a", "h", "c"], 3, ["d", "f", "b"]],
],
)
def test_010(lst, n, expected):
res = q.f010(lst, n)
assert res is None
assert lst == expected
@pytest.mark.parametrize(
"lst, expected",
[
[[3, None, 2, 5, 6], [3, 2, 5, 6, None]],
[[None, "f", "b", "a", None, "c"], ["f", "b", "a", "c", None, None]],
],
)
def test_011(lst, expected):
lst_bak = lst.copy()
res = q.f011(lst)
assert lst == lst_bak
assert res is not lst
assert res == expected
@pytest.mark.parametrize(
"lst, expected",
[
[[3, None, 2, 5, 6], [3, 2, 5, 6, None]],
[[None, "f", "b", "a", None, "c"], ["f", "b", "a", "c", None, None]],
],
)
def test_012(lst, expected):
res = q.f012(lst)
assert res is None
assert lst == expected
@pytest.mark.parametrize(
"hosts, ports, expected",
[
[
["www.cueb.edu.cn", "www.baidu.com", "www.google.com"],
[80, 443, 22],
["www.cueb.edu.cn:80", "www.baidu.com:443", "www.google.com:22"],
]
],
)
def test_013(hosts, ports, expected):
assert q.f013(hosts, ports) == expected
@pytest.mark.parametrize(
"lst, expected",
[
[[3, 1, 2], [2, 1, 3]],
[["d", "f", "b"], ["b", "f", "d"]],
],
)
def test_014(lst, expected):
res = q.f014(lst)
assert res is None
assert lst == expected
@pytest.mark.parametrize(
"lst, expected",
[[[3, 1, 2], [2, 1, 3]], [["d", "f", "b"], ["b", "f", "d"]]],
)
def test_015(lst, expected):
lst_bak = lst.copy()
res = q.f015(lst)
assert list(res) == expected
assert lst == lst_bak
@pytest.mark.parametrize(
"lst, expected",
[
[[3, 1, 2], [1, 2, 3]],
[["d", "f", "b"], ["b", "d", "f"]],
],
)
def test_016(lst, expected):
res = q.f016(lst)
assert res is None
assert lst == expected
@pytest.mark.parametrize(
"lst, expected",
[[[3, 1, 2], [1, 2, 3]], [["d", "f", "b"], ["b", "d", "f"]]],
)
def test_017(lst, expected):
lst_bak = lst.copy()
res = q.f017(lst)
assert list(res) == expected
assert lst == lst_bak
@pytest.mark.parametrize(
"lst, expected",
[[[3, 1, -2], [1, -2, 3]], [[4, 1, -3, 2], [1, 2, -3, 4]]],
)
def test_018(lst, expected):
lst_bak = lst.copy()
res = q.f018(lst)
assert list(res) == expected
assert lst == lst_bak
@pytest.mark.parametrize(
"lst, expected",
[
[[(4, 3), (5, 1), (3, 1)], [(4, 3), (3, 1), (5, 1)]],
[[(4, -3), (5, 5), (1, 2), (3, 1)], [(1, 2), (5, 5), (3, 1), (4, -3)]],
],
)
def test_019(lst, expected):
lst_bak = lst.copy()
res = q.f019(lst)
assert list(res) == expected
assert lst == lst_bak
@pytest.mark.parametrize(
"lst, order, expected",
[
[
["良好", "不及格", "优秀", "良好"],
["优秀", "良好", "及格", "不及格"],
["优秀", "良好", "良好", "不及格"],
],
[
["Tue", "Fri", "Tue", "Fri", "Mon"],
["Mon", "Tue", "Wen", "Thu", "Fri", "Sat", "Sun"],
["Mon", "Tue", "Tue", "Fri", "Fri"],
],
],
)
def test_020(lst, order, expected):
lst_bak = lst.copy()
res = q.f020(lst, order)
assert list(res) == expected
assert lst == lst_bak
@pytest.mark.parametrize(
"lst, expected",
[
[
[
["aaa", "bbb", "ccc"],
[3.112, 4.721, 1.874],
],
[
["aaa", 3.112],
["bbb", 4.721],
["ccc", 1.874],
],
],
[
[
["ddd", "eee"],
[8.764, 4.329],
[0.926, 3.927],
[5.551, 7.452],
],
[
["ddd", 8.764, 0.926, 5.551],
["eee", 4.329, 3.927, 7.452],
],
],
],
)
def test_021(lst, expected):
lst_bak = lst.copy()
res = q.f021(lst)
assert list(res) == expected
assert lst == lst_bak
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。