Generate an environ dict from the given arguments, make a request to the application using it, and return the response. :param args: Passed to :class:`EnvironBuilder` to create the environ for the request. If a single arg is passed, it can be an existing :cla
(
self,
*args: t.Any,
buffered: bool = False,
follow_redirects: bool = False,
**kwargs: t.Any,
)
| 1056 | return self.open(builder, buffered=buffered) |
| 1057 | |
| 1058 | def open( |
| 1059 | self, |
| 1060 | *args: t.Any, |
| 1061 | buffered: bool = False, |
| 1062 | follow_redirects: bool = False, |
| 1063 | **kwargs: t.Any, |
| 1064 | ) -> TestResponse: |
| 1065 | """Generate an environ dict from the given arguments, make a |
| 1066 | request to the application using it, and return the response. |
| 1067 | |
| 1068 | :param args: Passed to :class:`EnvironBuilder` to create the |
| 1069 | environ for the request. If a single arg is passed, it can |
| 1070 | be an existing :class:`EnvironBuilder` or an environ dict. |
| 1071 | :param buffered: Convert the iterator returned by the app into |
| 1072 | a list. If the iterator has a ``close()`` method, it is |
| 1073 | called automatically. |
| 1074 | :param follow_redirects: Make additional requests to follow HTTP |
| 1075 | redirects until a non-redirect status is returned. |
| 1076 | :attr:`TestResponse.history` lists the intermediate |
| 1077 | responses. |
| 1078 | |
| 1079 | .. versionchanged:: 2.1 |
| 1080 | Removed the ``as_tuple`` parameter. |
| 1081 | |
| 1082 | .. versionchanged:: 2.0 |
| 1083 | The request input stream is closed when calling |
| 1084 | ``response.close()``. Input streams for redirects are |
| 1085 | automatically closed. |
| 1086 | |
| 1087 | .. versionchanged:: 0.5 |
| 1088 | If a dict is provided as file in the dict for the ``data`` |
| 1089 | parameter the content type has to be called ``content_type`` |
| 1090 | instead of ``mimetype``. This change was made for |
| 1091 | consistency with :class:`werkzeug.FileWrapper`. |
| 1092 | |
| 1093 | .. versionchanged:: 0.5 |
| 1094 | Added the ``follow_redirects`` parameter. |
| 1095 | """ |
| 1096 | request: Request | None = None |
| 1097 | |
| 1098 | if not kwargs and len(args) == 1: |
| 1099 | arg = args[0] |
| 1100 | |
| 1101 | if isinstance(arg, EnvironBuilder): |
| 1102 | request = arg.get_request() |
| 1103 | elif isinstance(arg, dict): |
| 1104 | request = EnvironBuilder.from_environ(arg).get_request() |
| 1105 | elif isinstance(arg, Request): |
| 1106 | request = arg |
| 1107 | |
| 1108 | if request is None: |
| 1109 | builder = EnvironBuilder(*args, **kwargs) |
| 1110 | |
| 1111 | try: |
| 1112 | request = builder.get_request() |
| 1113 | finally: |
| 1114 | builder.close() |
| 1115 |
no test coverage detected