Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /TrueSelph_jvspatial /tests /utils /test_deprecation.py
| """Tests for jvspatial.utils.deprecation.deprecated decorator.""" | |
| import warnings | |
| from unittest.mock import patch | |
| import pytest | |
| from jvspatial.utils.deprecation import ( | |
| deprecated, | |
| reset_deprecation_warnings, | |
| ) | |
| def reset_state(): | |
| reset_deprecation_warnings() | |
| yield | |
| reset_deprecation_warnings() | |
| class TestSyncFunction: | |
| def test_first_call_emits_deprecation_warning(self): | |
| def f(): | |
| return 1 | |
| with warnings.catch_warnings(record=True) as caught: | |
| warnings.simplefilter("always", DeprecationWarning) | |
| assert f() == 1 | |
| assert len(caught) == 1 | |
| msg = str(caught[0].message) | |
| assert "test.api.dep_first" in msg | |
| assert "new_thing()" in msg | |
| assert "0.99.0" in msg | |
| def test_second_call_silent(self): | |
| def f(): | |
| return 1 | |
| with warnings.catch_warnings(record=True) as caught: | |
| warnings.simplefilter("always", DeprecationWarning) | |
| f() | |
| f() | |
| f() | |
| assert len(caught) == 1 | |
| def test_message_with_no_metadata_still_renders(self): | |
| def f(): | |
| return 1 | |
| with warnings.catch_warnings(record=True) as caught: | |
| warnings.simplefilter("always", DeprecationWarning) | |
| f() | |
| assert "Will be removed" in str(caught[0].message) | |
| class TestAsyncFunction: | |
| async def test_async_first_call_emits(self): | |
| async def f(): | |
| return "ok" | |
| with warnings.catch_warnings(record=True) as caught: | |
| warnings.simplefilter("always", DeprecationWarning) | |
| assert await f() == "ok" | |
| assert len(caught) == 1 | |
| class TestServerlessSuppression: | |
| def test_suppressed_in_serverless_mode(self): | |
| def f(): | |
| return 1 | |
| with patch( | |
| "jvspatial.utils.deprecation.is_serverless_mode", | |
| return_value=True, | |
| ): | |
| with warnings.catch_warnings(record=True) as caught: | |
| warnings.simplefilter("always", DeprecationWarning) | |
| f() | |
| f() | |
| assert caught == [] | |
Xet Storage Details
- Size:
- 2.58 kB
- Xet hash:
- 0814a58ca17963b3fb99d89639ece85c09e3344edc0327d11d0d1045165a5e8a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.