title: Struggling with 'synchronisation' between Session's in SQLAlchemy
body: <p>I've a created <code>delete_entity</code> function which delete's entities and I've a function which tests this functions.</p>
  
  <pre><code>#__init__.py
  engine = create_engine('sqlite://:memory')
  Session = scoped_session(sessionmaker(engine))
  
  # entity.py
  def delete_entity(id, commit=False):
    """ Delete entity and return amount of amount of rows affected. """
    rows_affected = Session.query(Entity).filter(Entity.id == id).delete()
    if commit:
      Session.commit()
      # Marker @A
  
    return rows_affected
  
  # test_entity.py
  def test_delete_entity(Session):
     # ... Here I add 2 Entity objects. Database now contains 2 rows.
  
     assert delete_entity(1) == 1                 # Not committed, row stays in database.
     assert delete_entity(1, commmit=True)        # Row should be deleted 
     # marker @B 
     assert len(Session.query(Entity).all()) == 1
  </code></pre>
  
  <p>This test passes when I run the <code>test_delete_entity()</code> <strong>alone</strong>. But when I run this test together with other tests this test fails. It fails on <code>assert len(Session.query(Entity)).all()) == 1</code>. The query finds 2 rows, so it looks like the row hasn't been deleted. 
  But, when I use the Python debugger (<code>pytest.set_trace()</code>) on @A and query for all Entity objects in the database I find 1 row. So the delete query was succesfull and one row has been deleted. But when I query for all Entity rows on @B I get 2 rows.</p>
  
  <p>How can I 'synchronize' both Sessions, so my test will pass?</p>