Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Conversation

@fawkesley
Copy link
Collaborator

back in 9c483376e4a562bbf0102a7b562695476fbd4699 I factored out
AssertErrorMixin, allowing tests to call self._assert_error(..)

Unfortunately this broke pytest's nice verbose assertion messages so
they look like this:

    def _assert_error(self, response, expected_status, expected_detail):
>       assert expected_status == response.status_code
E       AssertionError

this change means pytest knows to include AssertErrorMixin when it's
rewriting assertion code, so it looks like this again:

    def _assert_error(self, response, expected_status, expected_detail):
>       assert expected_status == response.status_code
E       AssertionError: assert 403 == 200
E        +  where 200 = <Response status_code=200,
"application/json">.status_code

mhep/dev/tests/views/mixins/assert_error.py:3: AssertionError

back in 9c483376e4a562bbf0102a7b562695476fbd4699 I factored out
AssertErrorMixin, allowing tests to call `self._assert_error(..)`

Unfortunately this broke pytest's nice verbose assertion messages so
they look like this:

```
    def _assert_error(self, response, expected_status, expected_detail):
>       assert expected_status == response.status_code
E       AssertionError
```

this change means pytest knows to include AssertErrorMixin when it's
rewriting assertion code, so it looks like this again:

```
    def _assert_error(self, response, expected_status, expected_detail):
>       assert expected_status == response.status_code
E       AssertionError: assert 403 == 200
E        +  where 200 = <Response status_code=200,
"application/json">.status_code

mhep/dev/tests/views/mixins/assert_error.py:3: AssertionError
```
@fawkesley fawkesley merged commit ccb1efc into master Dec 5, 2019
@fawkesley fawkesley deleted the fix-verbose-test-assertions branch December 5, 2019 10:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant