I'm using Pyramid framework for my application. I'm writing unit tests (tests.py file), where I want to:
get the actual request instead of dummyRequest and
also want to get the values of variables defined in config (development.ini) file.
I have gone through How to get an actual Pyramid request when unit testing question as well, but didn't get much from it.
Let me know how above can be achieved.
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:
Essentially, in your view function, you can use request.registry.settings
or pyramid.threadlocal.get_current_registry().settings
, it behaves like a dictionary.