A fixture that makes a real request object
authorKarl O. Pinc <kop@karlpinc.com>
Sun, 6 Dec 2020 19:12:11 +0000 (13:12 -0600)
committerKarl O. Pinc <kop@karlpinc.com>
Tue, 8 Dec 2020 04:08:34 +0000 (22:08 -0600)
README.rst
src/pgwui_testing/pytest_plugin.py

index 7aba57faaddc28db3e01c1acf4978260366630a6..41ecaf3ac2327e7414f058034369cd4d9c36227e 100644 (file)
@@ -53,6 +53,15 @@ This makes the following fixtures available:
     Side Effects: pyramid.threadlocal.get_current_request() returns
     a Pyramid DummyRequest instance.
 
+  pyramid_real_request_config
+    Input: path, \*\*kwargs
+
+    Is a (regular) Pyramid Configurator instance.
+
+    Side Effects: pyramid.threadlocal.get_current_request() returns
+    a (regular) Pyramid Request instance, created with a call to
+    pyramid.request.Request.blank(path, \*\*kwargs).
+
   pgwui__component_entry_point
     Input: A pgwui component name, as a string
 
index 025e55d42e34298cfb15ffc276b3a458e7f642e7..ed4b75b19e19641e4e31cfcf0582e3ec3eed7456 100644 (file)
@@ -31,6 +31,8 @@ from pyramid.testing import (
 
 from pgwui_testing import pytest_plugin_helpers
 
+import pyramid.request
+
 
 # Fixtures
 
@@ -47,6 +49,25 @@ def pyramid_request_config():
     tearDown()
 
 
+@fixture
+def pyramid_real_request_config(path, **kwargs):
+    '''Returns a Pyramid "testing" Configurator() instance.
+
+    Input:
+      path      An URL path
+      **kwargs  Configuration for a WebOb environ and a Pyramid request
+
+    When called with a path and kwargs, establishes a real Pyramid
+    Request() instance made available via
+    pyramid.threadlocal.get_current_request().  Calling the fixture
+    passes the fixture's arguments to a call to
+    pyramid.request.Request.blank(), to create the request.
+    '''
+    request = pyramid.request.Request.blank(path, **kwargs)
+    yield setUp(request=request)
+    tearDown()
+
+
 @fixture
 def pgwui_component_entry_point():
     '''Test that the supplied pgwui component is a pgui.components entry point