← Back to team overview

openerp-community team mailing list archive

Re: running test files from the cli

 

On 08/15/2011 05:15 PM, Viktor Nagy wrote:
> I've tried to play the good patriot and write a test for a coming
> commit, but can't run the pre-existing yaml test file.

Excellent! Not many people take the time to provide test cases for bug
report / patches, but they're really invaluable :-)


> the test file gets loaded, and I get the following error:
>
> ValueError: No references to account.account_invoice_customer0

As you guessed, the above error means that the system cannot find any
record in the database with the given ID "account_invoice_customer0".


> What point do I miss?

For large modules in the official distribution it is common to have
several distinct YAML test files, and sometimes they depend on each
other. This works during normal install/update processing because all
test files inside the same module are processed in the same database
transaction (and normally rolled back at the end).
Individual execution of some of these test files (with --test-file) may
then fail because they depend on data that is only available when the
previous test files have just been executed.

As Boris said, you must in this case execute a full update of the
relevant module with -u <MODULE> -d <DB> to force the execution of the
whole list of test files from that module.

You also mention having used "--test-commit". This could indeed cure the
issue by saving the test data in the database after executing the tests,
but you'd first need to pass this parameter when running a full
install/update on the account module (i.e. when the other test files are
executed and the test data is created).
However this is no silver bullet, because accounting objects have
workflows, so subsequent executions of the same tests would likely fail
because the dependent records may not be in the right state anymore (and
some workflows are meant to be irreversible).
So in your case, you're probably safer executing the full accounting
test suite again with -u.

PS: there used to be a name conflict causing failures when executing the
full test suite multiple times (due to bad name choices for Journals in
the Sales, POS and Stock test suites). If you encounter this, see
rev.4899 in trunk addons for the fix.


References