jgirardet / pytest-ponyorm

PonyORM in Pytest
GNU General Public License v3.0
4 stars 2 forks source link

Add option to not automatically run tests within dbsession #5

Open Elijas opened 5 years ago

Elijas commented 5 years ago

I noticed that when developing, I miss @dbsession decorator, since my tests pass, while in actual production not all my code will be automatically covered in session.

This is most relevant for integration tests.

I'd really appreciate having within_session with default True, so I could set it to False, when managing my own tests..

jgirardet commented 5 years ago

maybe not so simple, than it looks (plugin itself need a db_sesion to clean the database) I'll look into it

Elijas commented 5 years ago

Oh, I see :/ That would be awesome, thanks!

I really appreciate the plugin though, is there any way I could donate?

jgirardet commented 5 years ago

Hi, It's master, please try it before I push a new release. Just add db_session=False to decorator. I don't take donations but you can still ask to @ponyorm authors ;-)

Elijas commented 5 years ago

Thanks!

jgirardet commented 5 years ago

I'merge on master but I'll push release after I've fixed tests

Elijas commented 5 years ago

Ok, I got a little confused about the release plan here. Let me know if you need anything!

Elijas commented 5 years ago

Just to let you know - based on this SO answer, I realized that in my current project I should have all of my http endpoints under db_session anyway, so I won't manage them individually anymore.

So it's now completely up to you to decide whether this proposal should end up a part of pytest-ponyorm :)

peteretep commented 5 years ago

Hi, just got caught out on this one. Any plans to release the version that supports db_session=False ? I have tested the master branch version and notice that pytestmark = pytest.mark.pony(db_session=False) doesn't seem to work

Elijas commented 5 years ago

Hi, just got caught out on this one. Any plans to release the version that supports db_session=False ? I have tested the master branch version and notice that pytestmark = pytest.mark.pony(db_session=False) doesn't seem to work

From what I understand, this problem arises when you micro-manage session scopes, but you can just cover your code in a @db_session and you're fine https://github.com/jgirardet/pytest-ponyorm/issues/5#issuecomment-473571933

jgirardet commented 5 years ago

master is buggy, I forgot to finish it. why do you want db_session = False @peteretep ?

peteretep commented 5 years ago

I think I was micromanaging session scopes as @Elijas mentioned. All my tests were passing but failing in real life with db_session errors. is there some way to test for that in the current released version?

jgirardet commented 5 years ago

no not yet