test_oauth_auth_example.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:Stepik-API 作者: StepicOrg 项目源码 文件源码
def test_oauth_auth_example():
    import ast
    import _ast
    import codegen

    client_id = "n4mnzQGfDEfOhFixwBvLV2mZJJLvf86pzfMMiPF5"
    client_secret = "40ON9IPJRDAngUkVbGBTEjCBAwc2wB7lV8e71jJUPKabdKq6KBTUBKb1xGkh82KtAI1AqISrL3Zi4sTfhCBVh27YvlV6Y5klpXXV5loUWvuhMSRiN3HRZzVDO0fLBibv"

    with open("examples/oauth_auth_example.py", "r") as f:
        data = f.read()
        p = ast.parse(data)
    for node in p.body:
        if type(node) == _ast.Assign:
            if node.targets[0].id == 'client_id':
                node.value.s = client_id
            if node.targets[0].id == 'client_secret':
                node.value.s = client_secret
    ls = {}
    exec(codegen.to_source(p), ls)
    assert ls['course']['courses'][0]['id'] == 67
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号