Note that there are some explanatory texts on larger screens.

plurals
  1. POPython nose unit tests generating too many clients already
    primarykey
    data
    text
    <p>I'm using python 3.3, pyramid, sqlalchemy, psygopg2. I'm using a test postgres db for the unit tests. I have 101 unit tests set up for nose to run. On test 101 I get:</p> <blockquote> <p>nose.proxy.OperationalError: (OperationalError) FATAL: sorry, too many clients already</p> </blockquote> <p>It seems from the traceback that the exception is being thrown in</p> <blockquote> <p>......./venv/lib/python3.3/site-packages/SQLAlchemy-0.8.2-py3.3.egg/sqlalchemy/pool.py", line 368, in __connect</p> <pre><code> connection = self.__pool._creator() </code></pre> </blockquote> <p>Perhaps tearDown() is not running after each test? Isn't the connection pool limit for Postgresql 100 at one time?</p> <p>Here's my BaseTest class:</p> <pre><code>class BaseTest(object): def setup(self): self.request = testing.DummyRequest() self.config = testing.setUp(request=self.request) self.config.scan('../models') sqlalchemy_url = 'postgresql://&lt;user&gt;:&lt;pass&gt;@localhost:5432/&lt;db&gt;' engine = create_engine(sqlalchemy_url) DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) DBSession.configure(bind=engine) Base.metadata.bind = engine Base.metadata.create_all(engine) self.dbsession = DBSession def tearDown(self): testing.teardown() </code></pre> <p>My test classes inherit from BaseTest:</p> <pre><code>class TestUser(BaseTest): def __init__(self, dbsession = None): if dbsession: self.dbsession = dbsession def test_create_user(self): ...... ...... </code></pre> <p>One of the test classes tests a many-to-many relationship, so in that test class I first create the records needed to satisfy the foreign key relationships:</p> <pre><code>from tests.test_user import TestUser from tests.test_app import TestApp class TestAppUser(BaseTest): def __init__(self, dbsession = None): if dbsession: self.dbsession = dbsession def create_app_user(self): test_app = TestApp(self.dbsession) test_user = TestUser(self.dbsession) test_app.request = testing.DummyRequest() test_user.request = testing.DummyRequest() app = test_app.create_app() user = test_user.create_user() ...... </code></pre> <p>I'm passing the dbsession into the TestApp and TestUser classes...I'm thinking that is the source of the problem, but I'm not sure.</p> <p>Any help is greatly appreciated. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload