【问题标题】:SQLAlchemy unitest using json as a fixtureSQLAlchemy unitest 使用 json 作为夹具
【发布时间】:2013-10-11 01:21:10
【问题描述】:

Unitest 案例非常有用,尤其是对于缺少 UI 部分的项目。 我在 Django 中做了最简单的案例。首先使用缩进将表数据转储到 json 中

python manage.py dumpdata --indent=4  APP_NAME > FILENAME.json

然后在测试用例中使用这个 Fixture。

class MyAppTestCase(TestCase):
    fixtures = ['FILENAME.json']

    def test_index(self):
              pass

我在 SQLAlchemy 中寻找相同的东西。 SQLAlchemyFixture 可以,但不如 Django 方法使用 json 中的夹具来使用测试用例。 在 SQLAlchemy 中是否有人有任何方法可以做到这一点。

【问题讨论】:

    标签: django sqlalchemy


    【解决方案1】:

    使用fixture你可以将数据库内容转储到类似的对象中,但是python模块而不是json。见http://farmdev.com/projects/fixture/using-fixture-cmd.html

    【讨论】:

      猜你喜欢
      • 2011-10-25
      • 1970-01-01
      • 1970-01-01
      • 2020-06-27
      • 2021-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-27
      相关资源
      最近更新 更多