tests.py 文件源码

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

项目:utaustin-django-example 作者: singingwolfboy 项目源码 文件源码
def test_cached_home_page(client):
    response1 = client.get("/")
    assert response1.status_code == 200
    # insert a tweet into the database
    user = User(username="bob_ross")
    user.save()
    tweet = Tweet(content="happy little trees", creator=user)
    tweet.save()
    # check the homepage again -- it should *not* be updated,
    # due to the cache
    response2 = client.get("/")
    assert response2.status_code == 200
    assert "happy little trees" not in response2.content
    # flush the cache, and the tweet should appear!
    cache.clear()
    response3 = client.get("/")
    assert response3.status_code == 200
    assert "happy little trees" in response3.content
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号