diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 47ece6bef..000ba65e5 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -77,7 +77,9 @@ jobs: - env: "wsgi_servers" # E2E tests - env: "e2e_chrome" - - env: "e2e_firefox" + # TODO(vytas): Something is not working correctly with the + # newly released Firefox 131.0, SeleniumBase, and our tests. + # - env: "e2e_firefox" steps: - name: Checkout repo diff --git a/falcon/response.py b/falcon/response.py index b60529deb..209f6f0d0 100644 --- a/falcon/response.py +++ b/falcon/response.py @@ -209,6 +209,20 @@ def status_code(self) -> int: def status_code(self, value: int) -> None: self.status = value + @property + def body(self) -> NoReturn: + raise AttributeRemovedError( + 'The body attribute is no longer supported. ' + 'Please use the text attribute instead.' + ) + + @body.setter + def body(self, value: str) -> NoReturn: + raise AttributeRemovedError( + 'The body attribute is no longer supported. ' + 'Please use the text attribute instead.' + ) + @property def data(self) -> Optional[bytes]: """Byte string representing response content. diff --git a/tests/test_response.py b/tests/test_response.py index d986c7af9..da454147e 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -47,6 +47,17 @@ def test_add_link_removed(resp): resp.add_link('/things/1337', 'next') +def test_body_removed(resp): + # NOTE(kgriffs): Ensure AttributeRemovedError inherits from AttributeError + for exc_type in (AttributeError, AttributeRemovedError): + with pytest.raises(exc_type): + resp.body = '{"message": "Hello, World!"}' + + for exc_type in (AttributeError, AttributeRemovedError): + with pytest.raises(exc_type): + resp.body + + def test_response_attempt_to_set_read_only_headers(resp): resp.append_header('x-things1', 'thing-1') resp.append_header('x-things2', 'thing-2') diff --git a/tox.ini b/tox.ini index 767a018c7..1b0f225c6 100644 --- a/tox.ini +++ b/tox.ini @@ -431,14 +431,14 @@ commands = # -------------------------------------------------------------------- [testenv:e2e_chrome] -basepython = python3.10 +basepython = python3.12 deps = -r{toxinidir}/requirements/e2e commands = pytest {toxinidir}/e2e-tests/ --browser=chrome [testenv:e2e_firefox] -basepython = python3.10 +basepython = python3.12 deps = -r{toxinidir}/requirements/e2e commands =