Hi All,
Are there any libraries (or anything in sqlalchemy itself!) that cover
the pattern of running unit tests in against a database such that each
test gets its own sterile environment in which to run? Postgres, if it
helps. I've done some stuff with running in a subtransaction and rolling
Hello everyone,
I am working on a new project using SqlAlchemy Core 1.4 with Postgresql and
wanted to implement the following pattern for my tests:
- Before each test I would start a transaction (in a
@pytest.fixture(autorun=True))
- Each test may create its own transactions
- At the end of eac
On Wed, Mar 11, 2020, at 2:17 PM, Colton Allen wrote:
> Thank you. My use case didn't permit me to use your examples but, based on
> your advice, I ended up using "after_flush_postexec" event. Any consequences
> from doing this? Seems to work fine for now.
this is just the test suite right? if
Thank you. My use case didn't permit me to use your examples but, based on
your advice, I ended up using "after_flush_postexec" event. Any
consequences from doing this? Seems to work fine for now.
On Wednesday, March 11, 2020 at 12:34:12 PM UTC-5, Mike Bayer wrote:
>
>
>
> On Wed, Mar 11, 202
On Wed, Mar 11, 2020, at 12:44 PM, Colton Allen wrote:
> Hi,
>
> Before we talk about the read-replica, let's talk about the test suite as it
> is. I have a sessionmaker in my test suite configured to use an external
> transaction. Basically identical to this:
> https://docs.sqlalchemy.org/en
Hi,
Before we talk about the read-replica, let's talk about the test suite as
it is. I have a sessionmaker in my test suite configured to use an
external transaction. Basically identical to this:
https://docs.sqlalchemy.org/en/13/orm/session_transaction.html#joining-a-session-into-an-external
On 10/06/2019 15:40, Mike Bayer wrote:
Okay, so sounds like in an ideal world, the framework should provide a
way to sub out that transaction middleware when unit testing and then
for functional testing, I just need to fall back to dropping everything
in the db, or having a fresh db created fr
On Mon, Jun 10, 2019, at 2:09 AM, Chris Withers wrote:
> On 05/06/2019 20:47, Mike Bayer wrote:
> >
> >
> >> The panacea I'm after is to be able to run the DDL in a transaction, run
> >> each test in a subtransaction off that which is rolled back at the end
> >> of each test, but also be able t
On 05/06/2019 20:47, Mike Bayer wrote:
The panacea I'm after is to be able to run the DDL in a transaction, run
each test in a subtransaction off that which is rolled back at the end
of each test, but also be able to check that the code under test is
doing session.commit() where it should. Whe
On Wed, Jun 5, 2019, at 2:30 PM, Chris Withers wrote:
> On 05/06/2019 17:15, Mike Bayer wrote:
> >
> >> How come close() doesn't rollback the SessionTransaction if it throws it
> >> away?
> >
> > that's currently what .close() does, it discards the connection. this
> > is safe because the conn
On 05/06/2019 17:15, Mike Bayer wrote:
How come close() doesn't rollback the SessionTransaction if it throws it
away?
that's currently what .close() does, it discards the connection. this
is safe because the connection pool ensures transactions are rolled
back. This might have to change
On Wed, Jun 5, 2019, at 11:47 AM, Chris Withers wrote:
> On 05/06/2019 16:41, Mike Bayer wrote:
> >
> >> Which gives me:
> >>
> >> $ python sessions_are_weird.py
> >> Traceback (most recent call last):
> >> File "sessions_are_weird.py", line 40, in
> >> assert session.query(Event).count() == 0
On 05/06/2019 16:41, Mike Bayer wrote:
Which gives me:
$ python sessions_are_weird.py
Traceback (most recent call last):
File "sessions_are_weird.py", line 40, in
assert session.query(Event).count() == 0
AssertionError
Whereas after the rollback, I'd expect that count to be zero...
t
(sorry, meant to send this to the list)
On 05/06/2019 15:52, Mike Bayer wrote:
That session.close() appears to be the problem. It's a normal and
required part of the code under test, but it throws away the
SessionTransaction without rolling it back, so by the time the test
does session.roll
On Wed, Jun 5, 2019, at 3:50 AM, Chris Withers wrote:
> On 04/06/2019 23:21, Mike Bayer wrote:
>
>>
>> On Tue, Jun 4, 2019, at 4:33 PM, Chris Withers wrote:
>>>
>>> So, how do I roll back the further subtransaction created by the web
>>> framework instantiating Session from a sessionmaker bou
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 so
On 04/06/2019 23:21, Mike Bayer wrote:
On Tue, Jun 4, 2019, at 4:33 PM, Chris Withers wrote:
So, how do I roll back the further subtransaction created by the web
framework instantiating Session from a sessionmaker bound to the
connection in which begin_nested() has been called, which under non
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
On Tue, Jun 4, 2019, at 4:33 PM, Chris Withers wrote:
> On 04/06/2019 14:49, Mike Bayer wrote:
> >
> >
> > On Tue, Jun 4, 2019, at 2:15 AM, Chris Withers wrote:
> >> Now, what I'm trying to test is that I haven't forgotten to include
> >> the "with session.transaction". The problem is that, wi
On 04/06/2019 14:49, Mike Bayer wrote:
On Tue, Jun 4, 2019, at 2:15 AM, Chris Withers wrote:
Now, what I'm trying to test is that I haven't forgotten to include
the "with session.transaction". The problem is that, without the
transaction.rollback(), the test passes regardless of whether the
On Tue, Jun 4, 2019, at 2:15 AM, Chris Withers wrote:
> Hi All,
>
> I'm working with the pattern described at
> https://docs.sqlalchemy.org/en/13/orm/session_transaction.html#joining-a-session-into-an-external-transaction-such-as-for-test-suites
> along with pytest and FastAPI, an async web a
Hi All,
I'm working with the pattern described at
https://docs.sqlalchemy.org/en/13/orm/session_transaction.html#joining-a-session-into-an-external-transaction-such-as-for-test-suites
along with pytest and FastAPI, an async web app framework with good
support for running blocking code.
So, I
On Friday, March 29, 2019 at 7:35:02 PM UTC-4, Mike Bayer wrote:
>
>
> I'm assuming you mean a double equals sign there.
Yes. I am embarrassed
> I think I was assuming that user would come back with a great success
> story and this could be either on the wiki or maybe even an ext or a
> fl
On Fri, Mar 29, 2019 at 4:39 PM Jonathan Vanasco wrote:
>
> I was going batty trying to figure out why a unit test kept passing, while
> the functionality was clearly broken.
>
> I eventually realized the problem was a `filter` that didn't apply to the
> actual query.
>
> The code was essentiall
I was going batty trying to figure out why a unit test kept passing, while
the functionality was clearly broken.
I eventually realized the problem was a `filter` that didn't apply to the
actual query.
The code was essentially this:
result = s.query(Foo).filter(Bar.id = 1)
but it was diffi
Examining the stacktrace more closely revealed that I made the mistake of
checking for the error on the add but left the context of that error check
before committing. I actually did it the correct way in my all my other
tests so I'm not sure why I made the mistake at the very end.
My apologies
On Wed, Mar 7, 2018 at 11:30 AM, KCY wrote:
> In one of my tests I'm checking that a pair of (non primary) fields must be
> unique. This definition is done with:
>
> __table_args__ = (UniqueConstraint('entity_id', 'version',
> name='id_version_combined_unique'),)
>
> where `entity_id` is an INT co
In one of my tests I'm checking that a pair of (non primary) fields must be
unique. This definition is done with:
__table_args__ = (UniqueConstraint('entity_id', 'version', name=
'id_version_combined_unique'),)
where `entity_id` is an INT column referring to a foreign id and version is
a plain
On Oct 1, 2013, at 4:44 PM, Florian Rüchel wrote:
> I have created several custom types from base SQLAlchemy types. One example
> is a DateTime with integrated timezone support (i.e. it assumes all timezones
> are UTC when loading and attaches the tzinfo from pytz to it). Now I want to
> test
I have created several custom types from base SQLAlchemy types. One example
is a DateTime with integrated timezone support (i.e. it assumes all
timezones are UTC when loading and attaches the tzinfo from pytz to it).
Now I want to test these types. I could just integrate them in my usual
tests,
On Aug 23, 2013, at 6:34 PM, jason kirtland wrote:
>
> The patch seems like surprising Python behavior to me. Traversing across a
> None is almost certainly a bug in regular code, and quashing that error by
> default feels dangerous. I would want this to raise by default (and I have
> found
On Fri, Aug 23, 2013 at 2:31 PM, Gombas, Gabor (IT) <
gabor.gom...@morganstanley.com> wrote:
> On Fri, Aug 23, 2013 at 12:11:39PM -0700, Jonathan Vanasco wrote:
>
> > i think a simple fix could be something like this ( line 240,
> sqlalchemy/ext/associationproxy.py
> > )
> >
> > if self.sc
On Fri, Aug 23, 2013 at 12:11:39PM -0700, Jonathan Vanasco wrote:
> i think a simple fix could be something like this ( line 240,
> sqlalchemy/ext/associationproxy.py
> )
>
> if self.scalar:
> -if not getattr(obj, self.target_collection)
> -return self._scalar_ge
I have this general structure:
class Person:
# orm relationships are preceded by (o)ne or (l)ist
o_Person2Address_ActiveShipping = sa.orm.relationship( "
Person2Address", primaryjoin="""and_( Person2Address.person_id==Person.id ,
Person2Address.role_id=='active-shipping' )
When you say you created a setup fixture but it didn't work, what
didn't work exactly?
For example, if you just did something like this:
def setup():
engine = ...
Session = ...
session = Session()
...then that won't work because session is a local variable inside the
setup fu
On Tue, Apr 23, 2013 at 2:08 PM, Paradox wrote:
>
> On 04/23/2013 04:31 PM, Simon King wrote:
>>
>> On Tue, Apr 23, 2013 at 6:54 AM, Paradox wrote:
>>>
>>> I have a question related to sqlalchemy and testing, not sure if this is
>>> the
>>> best place to ask so let me know if I am asking here in
What do sqlalchemy users usually use for testing? I am willing to learn
other ways to do this that are more suited to the packages.
thomas
we use unittest
you can see how to setup session here
https://github.com/vice-versa/sacrud/blob/master/sacrud/tests/__init__.py
http://pytest.org/lates
On 04/23/2013 04:31 PM, Simon King wrote:
On Tue, Apr 23, 2013 at 6:54 AM, Paradox wrote:
I have a question related to sqlalchemy and testing, not sure if this is the
best place to ask so let me know if I am asking here in error.
I am trying to learn to write and run tests using py.test. Curr
On Tue, Apr 23, 2013 at 6:54 AM, Paradox wrote:
> I have a question related to sqlalchemy and testing, not sure if this is the
> best place to ask so let me know if I am asking here in error.
>
> I am trying to learn to write and run tests using py.test. Currently I am
> working on a spreadsheet s
I have a question related to sqlalchemy and testing, not sure if this is
the best place to ask so let me know if I am asking here in error.
I am trying to learn to write and run tests using py.test. Currently I
am working on a spreadsheet scrapper that gathers data from a directory
tree of spr
Hi Conor,
you were totally right in that I have to close the session, and then
the objects relating to my InnoDB can be re-queried and they have what
I expect. This is kind of a pain, as I'd like to be able to update
those objects continuously. I've modified my code so the session
closes when I
On 09/29/2010 01:47 PM, Conradaroma wrote:
> Hi,
>
> I am currently trying to move my DB tables over to InnoDB from MyISAM.
> I am having timing issues with requests and cron jobs that are running
> on the server that is leading to some errors. I am quite sure that
> transaction support will help m
Hi,
I am currently trying to move my DB tables over to InnoDB from MyISAM.
I am having timing issues with requests and cron jobs that are running
on the server that is leading to some errors. I am quite sure that
transaction support will help me with the problem. I am therefore
transitioning to In
Please read the document:
http://svn.sqlalchemy.org/sqlalchemy/trunk/README_MOVED_TO_MERCURIAL
Harry Percival wrote:
> how do I run some self-testing in sqlalchemy? I found this doc, but
> it seems to be out of date??
>
> http://svn.sqlalchemy.org/sqlalchemy/trunk/README.unittests
>
> just f
how do I run some self-testing in sqlalchemy? I found this doc, but
it seems to be out of date??
http://svn.sqlalchemy.org/sqlalchemy/trunk/README.unittests
just for fun, i'm trying to run these tests inside IronPython, so any
pointers in that direction would be helpful also..
thx,
HP
--
You
Hi,
I'm trying to test my web.py app, including its database
functionality. I would like to use a test database for this purpose,
but it seems like the standard web.py way of doing things is to
hardcode the database connection in something like a config.py file.
What's the best way to test a we
Hello,
I'm writing a basic SQLAlchemy application, and have started to
explore the concept of unit testing in general and specifically with
nose.
Since I am new to both SQLAlchey and nose, I do not know where to
start.
Right now the app is at the point where:
1) The tables are defined with dec
Hi. I am wanting to do some testing of an application that uses
SQLAlchemy 0.5.4, but I need to load some initial data to the
database.
When I searched for this in google, python-fixture appears as the
answer. But checking the page of python-fixture it doesn't seems work
for 0.5.
The question are
Hi,
Given a session object, is there a way to test if an object in the
session is pending (or for that matter, transient, persistent, or
detached)?
Thanks!
Demitri
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Group
Hello,
I'm working on a larger project which is using SQLAlchemy. We started
with writing automated tests using an in-memory SQLite database and
inserting test data in setUp() then emptying tables in tearDown().
Even though the in-memory SQLite is pretty fast, the process of
inserting test data (
How can I test whether a connection object is valid and hasn't, for
example, been time outed by the server?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sq
Hi,
I'm new to SQLAlchemy, and I was wondering if there's a way to test a
condition while inserting. I'm trying to make my application use as
few separate queries at the same time as possible. Here's a couple
cases I have had issues with:
Inserting something with a unique column if it doesn't e
52 matches
Mail list logo