Thanks guys.
Using this solves the problem:
from pyramid import paster
class FunctionalTests(unittest.TestCase):
def setUp(self):
app = paster.get_app('test.ini')
I understand that the paster module is not imported in the pyramid's
__init__, so it's not visible.
But why the hell does this work using `python setup.py test`:
import pyramid
import unittest
class FunctionalTests(unittest.TestCase):
def setUp(self):
app = pyramid.paster.get_app('test.ini')
And also I have some Integration tests using this base class:
import pyramid
class ViewIntegretionTest(unittest.TestCase):
def setUp(self):
self.config = pyramid.testing.setUp()
And this works perfectly well using `python setup.py test` or `nosetests`
or `python -m unittest discover`.
As far I understand this should not work at all. The `testing` module is
not imported in pyramid's __init__ file (just like the `paster` module).
Below is the pyramid's __init__ file of the pyramid version I'm working
with (1.3).
from pyramid.request import Request
from pyramid.response import Response
Response.RequestClass = Request
Request.ResponseClass = Response
del Request, Response
Thanks !
Le mercredi 27 juin 2012 00:01:06 UTC+2, Mike Orr a écrit :
>
> It would be visible in the parent package (pyramid) only if the
> __init__.py imported it.
>
> On Tue, Jun 26, 2012 at 10:18 AM, Michael Merickel <[email protected]>wrote:
>
>> "import pyramid.paster" should fix it. I never use submodules without
>> importing them directly, mainly because I don't understand how Python
>> handles it.
>>
>> On Tue, Jun 26, 2012 at 11:20 AM, Emmanuel Cazenave <[email protected]>
>> wrote:
>> > Hi everyone,
>> >
>> > I'm writing functional tests in a pyramid application.
>> > Below is the base class I use to write functionals tests.
>> >
>> > import pyramid
>> > import unittest
>> > from myapp.models import DBSession
>> >
>> > class FunctionalTests(unittest.TestCase):
>> >
>> > def setUp(self):
>> > app = pyramid.paster.get_app('test.ini')
>> > Base.metadata.create_all(DBSession.get_bind())
>> > from webtest import TestApp
>> > self.testapp = TestApp(app)
>> >
>> > def tearDown(self):
>> > del self.testapp
>> > Base.metadata.drop_all(DBSession.get_bind())
>> > DBSession.remove()
>> >
>> > Everything goes fine when I run my tests using `python setup.py test`
>> (my
>> > setup.py is a setuptools one)
>> >
>> > And everything goes wrong when I run it using the `nosetests` command or
>> > even the standard unittest discover command: `python -m unittest
>> discover`
>> > In both cases every functional test produces the following error:
>> >
>> > Traceback (most recent call last):
>> > File "myapp/tests/__init__.py", line 31, in setUp
>> > app = pyramid.paster.get_app('test.ini')
>> > AttributeError: 'module' object has no attribute 'paster'
>> >
>> > I'm quite completely lost on this one. Any idea ?
>> >
>> > Thanks
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "pylons-discuss" group.
>> > To view this discussion on the web visit
>> > https://groups.google.com/d/msg/pylons-discuss/-/6-ljzzzCTpoJ.
>> > 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 view this discussion on the web visit
https://groups.google.com/d/msg/pylons-discuss/-/h3wE5AtjjxQJ.
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.