1 Star 0 Fork 136

刘平/e0501-builtins

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
e01_str_test.py 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
高强 提交于 2022-04-20 17:00 . First draft finished
import pytest
import e01_str_quiz as q
def test_001():
# 不要学这里的代码, 这不是标准答案
assert q.A001 == b"a string with \x27single\x27 quotes".decode()
def test_002():
# 不要学这里的代码, 这不是标准答案
assert q.A002 == b"a string with \x22double\x22 quotes".decode()
def test_003():
# 不要学这里的代码, 这不是标准答案
assert (
q.A003
== b"a string with \x27single\x27 and \x22double\x22 quotes".decode()
)
def test_004():
assert q.Q004 == q.A004
def test_005():
# 不要学这里的代码, 这不是标准答案
assert q.A005 == b"t\x09t\x09t".decode()
def test_006():
# 不要学这里的代码, 这不是标准答案
assert q.A006 == b"n\x0An\x0An".decode()
@pytest.mark.parametrize(
"code, exchange, res",
[
["600519", "SH", "600519.SH|600519sh|SH600519"],
["300750", "sz", "300750.SZ|300750sz|SZ300750"],
["835185", "Bj", "835185.BJ|835185bj|BJ835185"],
],
)
def test_007(code, exchange, res):
assert q.f007(code=code, exchange=exchange) == res
@pytest.mark.parametrize(
"number, output",
[
[15, "00001111"],
[42, "00101010"],
[240, "11110000"],
],
)
def test_008(number, output, capsys):
q.f008(number)
out, err = capsys.readouterr()
assert out == output + "\n"
@pytest.mark.parametrize(
"args, joined",
[
[["/bin", "/usr/bin"], "/bin:/usr/bin"],
[
["/bin", "/usr/bin", "/usr/local/bin"],
"/bin:/usr/bin:/usr/local/bin",
],
[["/home"], "/home"],
],
)
def test_009(args, joined):
assert q.f009(*args) == joined
@pytest.mark.parametrize(
"split, joined",
[
[["/bin", "/usr/bin"], "/bin:/usr/bin"],
[
["/bin", "/sbin", "/usr/local/bin"],
"/bin:/sbin:/usr/local/bin",
],
[["/home"], "/home"],
],
)
def test_010(split, joined):
assert q.f010(joined) == split
@pytest.mark.parametrize(
"filename, name, ext",
[
["README.txt", "README", "txt"],
["script.py", "script", "py"],
["backup.tar.gz", "backup.tar", "gz"],
],
)
def test_011(filename, name, ext):
res = q.f011(filename)
assert res == (name, ext)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/liu-ping0318/e0501-builtins.git
git@gitee.com:liu-ping0318/e0501-builtins.git
liu-ping0318
e0501-builtins
e0501-builtins
master

搜索帮助