python、postgresql中的数据库测试 [英] Database testing in python, postgresql

查看:34
本文介绍了python、postgresql中的数据库测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何对使用 postgresql 的 python DAL 进行单元测试.

How do you unit test your python DAL that is using postgresql.

在 sqlite 中,您可以为每个测试创建内存数据库,但对于 postgresql 则不能这样做.

In sqlite you could create in-memory database for every test but this cannot be done for postgresql.

我想要一个可用于设置数据库并在测试完成后对其进行清理的库.

I want a library that could be used to setup a database and clean it once the test is done.

我使用 Sqlalchemy 作为我的 ORM.

I am using Sqlalchemy as my ORM.

推荐答案

您可以使用 nose 编写您的测试,然后只需使用 SQLAlchemy 在您的 设置/拆卸 方法.

You can use nose to write your tests, then just use SQLAlchemy to create and clean the test database in your setup/teardown methods.

这篇关于python、postgresql中的数据库测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆