Hi,

found the error myself. The problem was that I have my tests outside the
product. So doing a config.scan only scans the test product and not the
Pyramid product. Adding a config.scan('<pyramidproductname>') did the
trick.

Regards
   Estartu

Am 10.08.2018 um 20:57 schrieb Oliver:
> You should include your route setup before, so that your registry gets 
> populated.
> 
> I usually use pytest and its fixtures to have access to everything I need in 
> testing, e.g. something like this:
> 
> import pytest
> 
> @pytest.fixture(scope='session')
> def test_settings():
>     import plaster
>     test_settings = plaster.get_settings('testing.ini', 'app:main')
>     return test_settings
> 
> 
> @pytest.fixture
> def test_registry():
>     from pyramid import registry
>     reg = registry.Registry('testing')
>     return reg
> 
> 
> @pytest.fixture
> def test_request(test_registry):
>     from pyramid import request
>     req = request.Request({})
>     req.registry = test_registry
>     return req
> 
> 
> @pytest.fixture
> def test_config(test_settings, test_registry, test_request):
>     from pyramid import testing
>     config = testing.setUp(registry=test_registry, request=test_request, 
> settings=test_settings)
>     yield config
>     testing.tearDown()
> 
> 
> def test_foobar(test_config):
>     test_config.include('your.feature')
>     # assert something
> 
> 
> test_settings fixture lives normally in the root conftest.py and the others 
> where I need them.
> 
> 
> 
> cheers
> Oliver
> 
> On 10.08.2018 17:26, Gerhard Schmidt wrote:
>> Hi,
>>
>> I'm writing a pyramid software using traversal with quite some complex
>> ways of finding views and testing permissions to the view.
>>
>> Everything works quite well in the running pyramid server but in
>> unit-tests the views that are there aren't found.
>>
>> I use the following code to get the callable of a view.
>>
>> adapters = registry.adapters
>> context_iface = providedBy(context)
>> view_callable = adapters.lookup(
>>         (IViewClassifier, request.request_iface, context_iface),
>>         IView, name=request.view_name, default=None)
>>
>> In the running server this code works fine, in unit-tests it returns
>> None all the time.
>>
>> I use a request object derived from pyramid.testing.DummyRequest.
>>
>> Can anybody give me a pointer what I'm doing wrong.
>>
>> Regards
>>     Estartu
>>
> 

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/7c76a56b-6ca0-a21f-faa2-0caafaf99469%40augusta.de.
For more options, visit https://groups.google.com/d/optout.

Reply via email to