Daily updates from Odoo
Monday, January 21, 2019
1 change · master
New functionality added to Odoo
This change adds a new test command that makes it easier for teams to run only the Odoo tests they need, helping reduce feedback time during development. It also includes cleanup and reliability fixes across several test areas, improving maintainability without directly changing day-to-day business workflows.
Original PR description
## Test subcommand Adds a test subcommand through py.test (with ~all py.test options forwarded directly): - flexible testing specification, the subcommand can take Odoo modules, directories and/or…
## Test subcommand Adds a test subcommand through py.test (with ~all py.test options forwarded directly): - flexible testing specification, the subcommand can take Odoo modules, directories and/or files as positional parameters and will apply [py.test's discovery conventions](http://pytest.org/latest/goodpractises.html#test-discovery) to fetch Python test cases, "data" test cases will be extracted from a module's `__openerp__.py` if that matches other filters - _only runs selected tests_, if requesting the testing of `product` all its dependencies (and auto_install dependents) are installed (with demo data) but only the tests of `product` are run - with no positional parameters, just starts looking for tests in the current working directory - automatically creates and deletes a temporary db if none is provided, if one is provided does not delete it (but creates it if it's missing) which can allow reusing dbs - uses an inited (but not specifically configured) Odoo logger and a pytest in default display mode (line per test file, captures stdout/stderr) - recap at the end of testing with display of failed test stack traces & captured stderr/stdout - provided marks to ignore categories of tests, only current mark is `http` so `odoo.py test -m 'not http'` will not start an http server and won't run any HTTP test - existing "unittest" tests mostly work as-is (unless they were mucking with the registry or even runtest protocol), alternatively can write lighter "pytest" tests - fixtures make for pretty clean setup/teardown & composition - slightly to greatly faster tests depending on the selected module(s) - future improvements via existing addons (e.g. [pep8](https://pypi.python.org/pypi/pytest-pep8), [coverage](https://pypi.python.org/pypi/pytest-cover)) or more formal results reporting (e.g. [junitxml result logs](http://pytest.org/latest/usage.html#creating-junitxml-format-files)) or new addons for e.g. better JS or tour integration e.g. `odoo.py test mail account` (will run all non-skipped tests in the mail and account addons), `odoo.py test addons/product/tests/test_pricelist.py` (will just run the two test cases in test_pricelist.py), `odoo.py test --pdb -k test_20_pricelist_uom` (will only run that test case, should drop into pdb if the test fails) ## `--test-enable` - most of the registry-installation functions moved to methods of Registry - Registry.load_modules changed to a coroutine and testing part moved outside of it to RegistryManager.new, which external runner does _not_ use see 3219863 - "on-install" testing uses same test discovery subcommand does with custom test reporter - reporting not identical to old reporting but pretty close (and improvement in some ways) - replaced old assertion_reporter (which just counted) by normal assertion errors in XML and YAML - all failed tests summarised/printed at the end of installation, no need to go hunt in the log - remains compatible with runbot (I think, went into runbot source to see how that worked) ## other changes - some tests were implicitly skipped (weren't imported by test package), changed to explicit skipping - various imports improved, some of them may not be necessary after all. May be useful if we eventually try to make just calling `py.test` directly possible - moved and removed imports so pytest and unittest2 are only imported when actually trying to _run_ tests - removed `--test-file` behaviour, superseded by `odoo.py test <testfile>` /cc @odony @antonylesuisse @tde-banana-odoo