Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easy access to ORM Environment? #19

Open
erkesado opened this issue May 29, 2018 · 4 comments
Open

Easy access to ORM Environment? #19

erkesado opened this issue May 29, 2018 · 4 comments

Comments

@erkesado
Copy link

First of all, thanks for a great pytest plugin.
I wonder if there is an easy way to access to ORM Environment like self.env['res.users'] ....
I have searched in pytest_odoo.py file. But I can't find anything related to the access of ORM Environment.
If it does not have an easy way of accessing ORM Environment right, I guess it should be right in the pytest-odoo. It is mindless to develop an another pytest plugin. It is mindless to copy/paste in every module.
If there is no such thing yet, I am eager to help doing it in the pytest-odoo.

@guewen
Copy link
Contributor

guewen commented Jun 14, 2018

Can you tell me more about your usage of pytest-odoo? Do you run "pytest" tests with it?

The use case the lib tries to cover now is to run the tests built in odoo addons which are using python's unittest, but with the comfort of the pytest CLI. These odoo's unittest tests classes already include all the boilerplate to open a cursor, environment and so on.

I do prefer a lot pytest tests over unittest, but we solely use the latter inside Odoo addons because they can also be run by the odoo machinery (--test-enable) (but also to benefit from some base tests classes that we can inherit from).

Thinking about it, there is probably a way to run pytest tests from a unittest class, which would allow to write tests as pytest but make them available from --test-enable.

So I'm looking forward to discussing your usage :)

@erkesado
Copy link
Author

erkesado commented Jun 15, 2018

We used to use unittest in Odoo addons. But now we prefer pytest. We will use pytest in all our Odoo modules and convert existing unittest code to pytest. I think pure pytest is better. Running pytest inside a unittest class will blur simplicity and easiness of pytest. The another reason for shifting to pytest from unittest is that we are implementing BDD in Odoo development. pytest supports BDD through pytest-bdd and Odoo supports pytest through pytest-odoo.
Even though our usage of pytest-odoo is 0% now, it will be 100% for our modules soon.

@dcrocco
Copy link

dcrocco commented Jul 13, 2018

@erkesado Would you mind on giving an example of how you want to use it?

@voronind
Copy link

IMHO to write pytest tests for your own addons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants