``sqlahelper.reset()`` exists mainly for SQLAHelper's own unit tests. I don't know whether it's appropriate for Pyramid app tests. I can clarify this in the documentation if we decide one way or the other.
I wonder if Pyramid needs a Nose plugin like Pylons does, so that --with-pylons=test.ini loads a configuration that sets the db binding globally, so that it doesn't have to be set for each test. On Tue, Mar 6, 2012 at 5:05 AM, Atsushi Odagiri <[email protected]> wrote: > Hi > > I have some question for this problem. > > when do you call `sqlahelper.add_engine`? > and don't you call `sqlahelper.reset`? > > if you call `sqlahelper.reset`, and you must reload `models` module. > > regards > > > 2012/3/6 Benjamin Sims <[email protected]> >> >> I'm not sure specifically why it would be triggered (not experienced this >> before with other projects using Deform). >> >> In any case, I was able to solve by refining the test suite setting in >> setup.py, specifing myproject.tests rather than just myproject. >> >> Thanks, >> Ben >> >> >> On 5 March 2012 20:41, Mike Orr <[email protected]> wrote: >>> >>> So Deform is trying to resolve a table schema at import. I don't know >>> about Deform schemas, but what's probably happening is that with >>> pserve, the engine is configured and bound before the view scan is >>> called, but in the test environment it's importing the model looking >>> for tests, and thus triggering the code before main() has been called. >>> This often happens in unit tests, in Pylons and other frameworks. The >>> general solution is to move the code into a function or arrange for >>> that module not to be scanned, but I don't know how to apply this to >>> Deform. >>> >>> On Mon, Mar 5, 2012 at 2:31 AM, Benjamin Sims <[email protected]> >>> wrote: >>> > Thanks for the help, >>> > >>> > Relevant section of the traceback is as follows: >>> > >>> > >>> > File >>> > >>> > "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", >>> > line 91, in loadTestsFromName >>> > module = __import__('.'.join(parts_copy)) >>> > File "/Users/benjamin/Project/app/dev/Project/project/schemas.py", >>> > line >>> > 171, in <module> >>> > class TheSchema(colander.Schema): >>> > File "/Users/benjamin/Project/app/dev/Project/project/schemas.py", >>> > line >>> > 176, in TheSchema >>> > widget = deform.widget.SelectWidget(values=helper()), >>> > File "/Users/benjamin/Project/app/dev/Project/project/schemas.py", >>> > line >>> > 168, in helper >>> > # SQLA query is done here >>> > >>> > It seems that the unittest loader is loading the schema class as one of >>> > its >>> > tests, which then makes the helper call and fails. >>> > >>> > Commenting out the TheSchema class allows the test to run as normal. >>> > >>> > Thanks, >>> > Ben >>> > >>> > On 2 March 2012 19:05, Mike Orr <[email protected]> wrote: >>> >> >>> >> On Fri, Mar 2, 2012 at 3:16 AM, Benjamin Sims <[email protected]> >>> >> wrote: >>> >> > on the grounds that there is no bind for DBSession in helper() >>> >> > above. I >>> >> > understand that there is no bind, but helper is not called >>> >> > explicitly >>> >> > nor >>> >> > required by anything in the tests. >>> >> >>> >> Does the traceback say who called helper()? What happens if you >>> >> comment out the helper function? >>> >> >>> >> -- >>> >> Mike Orr <[email protected]> >>> >> >>> >> -- >>> >> You received this message because you are subscribed to the Google >>> >> Groups >>> >> "pylons-discuss" group. >>> >> To post to this group, send email to [email protected]. >>> >> To unsubscribe from this group, send email to >>> >> [email protected]. >>> >> For more options, visit this group at >>> >> http://groups.google.com/group/pylons-discuss?hl=en. >>> >> >>> > >>> > -- >>> > You received this message because you are subscribed to the Google >>> > Groups >>> > "pylons-discuss" group. >>> > To post to this group, send email to [email protected]. >>> > To unsubscribe from this group, send email to >>> > [email protected]. >>> > For more options, visit this group at >>> > http://groups.google.com/group/pylons-discuss?hl=en. >>> >>> >>> >>> -- >>> Mike Orr <[email protected]> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "pylons-discuss" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/pylons-discuss?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "pylons-discuss" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/pylons-discuss?hl=en. > > > > > -- > /* > Atsushi Odagiri > http://blog.aodag.jp > mailto:[email protected] > */ > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/pylons-discuss?hl=en. -- Mike Orr <[email protected]> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
