For your first "want", you can see this well-written SO post: How to get an actual Pyramid request when unit testing
It suggests to utilize the DummyRequest
. "The thing to realize whenever you are unit testing (which is different from functional tests) is that you are testing a small 'unit'. This unit does not require a 'real' request, nor does it require a fully working system."
For your second "want", you can refer to the (1) Pyramid docs and (2) an SO post:
- http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html#adding-a-custom-setting
- how can i get the ini data in pyramid?
Essentially, in your view function, you can use request.registry.settings
or pyramid.threadlocal.get_current_registry().settings
, it behaves like a dictionary.