From 40faddfcbdde66d94f4306848374faff3543eac7 Mon Sep 17 00:00:00 2001 From: Luca Giovenzana Date: Tue, 14 Nov 2023 22:58:01 +0100 Subject: [PATCH] fix: status should be evaluate latest response if failed #383 --- atests/issues/334.robot | 13 +++++++++++++ atests/test_status_assertions.robot | 1 - src/RequestsLibrary/RequestsKeywords.py | 2 +- src/RequestsLibrary/version.py | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 atests/issues/334.robot diff --git a/atests/issues/334.robot b/atests/issues/334.robot new file mode 100644 index 0000000..f58426b --- /dev/null +++ b/atests/issues/334.robot @@ -0,0 +1,13 @@ +*** Settings *** +Library RequestsLibrary +Resource ../res_setup.robot + +Suite Setup Setup Flask Http Server +Suite Teardown Teardown Flask Http Server And Sessions + +*** Test Cases *** + +Test evaluated response is always the one passed + ${response_error}= GET On Session ${GLOBAL_SESSION} url=/status/404 expected_status=any + ${response_ok}= GET On Session ${GLOBAL_SESSION} url=/status/200 expected_status=any + Status Should Be 404 ${response_error} diff --git a/atests/test_status_assertions.robot b/atests/test_status_assertions.robot index 8716b68..3cf12ab 100644 --- a/atests/test_status_assertions.robot +++ b/atests/test_status_assertions.robot @@ -5,7 +5,6 @@ Resource res_setup.robot Suite Setup Setup Flask Http Server Suite Teardown Teardown Flask Http Server And Sessions - *** Test Cases *** Request And Status Should Be Different diff --git a/src/RequestsLibrary/RequestsKeywords.py b/src/RequestsLibrary/RequestsKeywords.py index ad0133a..ac3bce8 100644 --- a/src/RequestsLibrary/RequestsKeywords.py +++ b/src/RequestsLibrary/RequestsKeywords.py @@ -116,7 +116,7 @@ def status_should_be(self, expected_status, response=None, msg=None): | ELSE | [...] """ - if not response: + if response is None: response = self.last_response self._check_status(expected_status, response, msg) diff --git a/src/RequestsLibrary/version.py b/src/RequestsLibrary/version.py index 8377f8d..4d65845 100644 --- a/src/RequestsLibrary/version.py +++ b/src/RequestsLibrary/version.py @@ -1 +1 @@ -VERSION = '0.9.5' \ No newline at end of file +VERSION = '0.9.6'