Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /gradio-app_gradio /test /test_analytics.py
| import json | |
| import os | |
| import warnings | |
| from unittest.mock import patch | |
| from gradio import analytics | |
| os.environ["GRADIO_ANALYTICS_ENABLED"] = "False" | |
| class TestAnalytics: | |
| def test_should_warn_with_unable_to_parse(self, mock_get, monkeypatch): | |
| monkeypatch.setenv("GRADIO_ANALYTICS_ENABLED", "True") | |
| mock_get.side_effect = json.decoder.JSONDecodeError("Expecting value", "", 0) # type: ignore | |
| with warnings.catch_warnings(record=True) as w: | |
| warnings.simplefilter("always") | |
| analytics.version_check() | |
| assert ( | |
| str(w[-1].message) | |
| == "unable to parse version details from package URL." | |
| ) | |
| def test_error_analytics_doesnt_crash_on_connection_error( | |
| self, mock_send, monkeypatch | |
| ): | |
| monkeypatch.setenv("GRADIO_ANALYTICS_ENABLED", "True") | |
| mock_send.side_effect = Exception("Connection error") | |
| analytics._do_normal_analytics_request("placeholder", {}) | |
| mock_send.assert_called() | |
| def test_error_analytics_successful(self, mock_post, monkeypatch): | |
| monkeypatch.setenv("GRADIO_ANALYTICS_ENABLED", "True") | |
| analytics.error_analytics("placeholder") | |
Xet Storage Details
- Size:
- 1.35 kB
- Xet hash:
- 692638b09c0fc3e2e1fef93cca5a8d967118ac633f198ef32e9ef492721de87a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.