Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Status Should Be" uses last request even if a response is provided #383

Closed
apallier opened this issue Nov 9, 2023 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@apallier
Copy link

apallier commented Nov 9, 2023

Version: 0.9.2 (but should exit in every versions until now)

Steps to reproduce

Here a minimal code reproducing the problem:

*** Settings ***
Library    RequestsLibrary

*** Test Cases ***
Test
    ${response_error}=     GET    https://www.google.com/404    expected_status=any
    ${response_ok}=     GET    https://www.google.com    expected_status=any
    Status Should Be    404    ${response_error}

Actual result

Keyword Status Should Be fails:

==============================================================================
Bug Requests Library                                                          
==============================================================================
Test                                                                  | FAIL |
Url: https://www.google.com/ Expected status: 200 != 404
------------------------------------------------------------------------------
Bug Requests Library                                                  | FAIL |
1 test, 0 passed, 1 failed
==============================================================================

Actual result

Keyword Status Should Be should pass because response ${response_error} is actually a 404 error

Investigation

  1. It seems that a Requests Response in error is considered as "False". See this code

  2. And so the following code takes the "last response" if the Response is in error (the response provided in parameter is ignored): See this code :

@keyword("Status Should Be")
def status_should_be(self, expected_status, response=None, msg=None):
    if not response:
        response = self.last_response
    self._check_status(expected_status, response, msg)
@lucagiove
Copy link
Member

Ouch, thanks for the detailed report I'll have a look

@lucagiove lucagiove added this to the 0.9 milestone Nov 10, 2023
@lucagiove lucagiove added the bug label Nov 10, 2023
@lucagiove lucagiove self-assigned this Nov 10, 2023
@lucagiove lucagiove modified the milestones: 0.9, 1.0 Nov 14, 2023
lucagiove added a commit that referenced this issue Nov 14, 2023
…ast-request-even-if-a-response-is-provided

#383 status should be uses last request even if a response is provided
@apallier
Copy link
Author

Thanks for the fix 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants