你如何运行OpenERP yaml单元测试

Tim*_*olo 15 yaml unit-testing openerp openerp-8

我正在尝试在我的openERP模块上运行单元测试,但无论我写什么,它都不会显示测试是否通过!有谁知道如何输出测试结果?(使用Windows OpenERP 6.1版)

我的YAML测试是:

- 
  I test the tests
-
  !python {model: mymodelname}: |
    assert False, "Testing False!"
    assert True, "Testing True!"
Run Code Online (Sandbox Code Playgroud)

我用openerp-server.exe重新加载模块时的输出--update mymodule --log-level = test -dtestdb显示测试运行但没有错误?!

... TEST testdb openerp.tools.yaml_import: I test the tests
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

编辑:------------------------------------------------ ---------------------

好吧,经过多次摆弄!python,我尝试了另一个测试:

- 
    I test that the state
-
!assert {model: mymodel, id: mymodel_id}:
    - state == 'badstate'
Run Code Online (Sandbox Code Playgroud)

这给了预期的失败:

WARNING demo_61 openerp.tools.yaml_import: Assertion "NONAME" FAILED
test: state == 'badstate'
values: ! active == badstate
Run Code Online (Sandbox Code Playgroud)

所以我猜我的语法有问题,可能会在版本7中按预期工作.

感谢大家的回答和帮助!

nay*_*nay 9

这就是我尝试过的.它似乎对我有用:

!python {model: sale.order}: |
    assert True, "Testing True!"
    assert False, "Testing False!"
Run Code Online (Sandbox Code Playgroud)

(也许你忘记了"|"字符)

然后 :

bin/start_openerp --init=your_module_to_test -d your_testing_database --test-file=/absolute/path/to/your/testing_file.yml
Run Code Online (Sandbox Code Playgroud)

您可能希望在创建测试数据库之前:

createdb mytestdb --encoding = unicode

希望它能帮到你

更新:这是我的日志(我称我的测试文件为sale_order_line_test.yml)

ERROR mytestdb openerp.tools.yaml_import: AssertionError in Python code : Testing False!
mytestdb openerp.modules.loading: At least one test failed when loading the modules.
loading test file /path/to/module/test/sale_order_line_test.yml
AssertionError in Python code : Testing False!
Run Code Online (Sandbox Code Playgroud)