On Tue, Jun 4, 2019, at 6:31 PM, Chris Withers wrote:
> On 04/06/2019 23:21, Mike Bayer wrote:
> > 
> > 
> > I'm not following all your code but if there are two sessions in play 
> > I'd probably try to avoid that, there should be only one Session you 
> > care about. 
> 
> This comes back to something I asked you about on Twitter a while ago: 
> the code under test gets its session by calling a sessionmaker; how can 
> I have that return an existing session, which appears to be what you're 
> suggesting, rather than a new suggestion, which appears to be all they 
> can do.


yeah you have to inject and mock aggressively so that your code being tested 
only sees the Session objects your fixtures want them to.

> 
> > the test fixtures should be external to everything 
> 
> I don't understand what you mean by this.

the same thing as my statement above. The code being tested shouldn't be able 
to make it's own Session if you want it to have one that you are controlling, 
which means when your test harness runs it has to swap out everything in the 
application that might be in the way of this. The term "harness" implies your 
entire application sits "inside" the harness, that's what I mean by "external".

> 
> > and make 
> > sure there's just the one session. if there are two in play, I'm not 
> > sure how they both get bound to your test transaction.
> 
> I believe they start a nested transaction?

one Session has nothing to do with another so I don't know what you mean.


> 
> Chris
> 
> -- 
> SQLAlchemy - 
> The Python SQL Toolkit and Object Relational Mapper
> 
> http://www.sqlalchemy.org/
> 
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
> --- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/50bb9529-f98b-24aa-484f-1274c8fe3290%40withers.org.
> For more options, visit https://groups.google.com/d/optout.
> 

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/9953dcf8-d491-418c-ae1f-73c91f7666a6%40www.fastmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to