test hotfix (#1705)

* test hotfix

* init
This commit is contained in:
Abubakar Abid 2022-07-04 15:29:19 -07:00 committed by GitHub
parent 8c9419fce1
commit 68afe67497
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 18 deletions

View File

@ -67,5 +67,5 @@ from gradio.templates import (
Webcam,
)
current_pkg_version = pkgutil.get_data(__name__, "version.txt").decode('ascii').strip()
current_pkg_version = pkgutil.get_data(__name__, "version.txt").decode("ascii").strip()
__version__ = current_pkg_version

View File

@ -7,6 +7,7 @@ import inspect
import json
import json.decoder
import os
import pkgutil
import random
import sys
import warnings
@ -38,7 +39,9 @@ JSON_PATH = os.path.join(os.path.dirname(gradio.__file__), "launches.json")
def version_check():
try:
current_pkg_version = pkg_resources.require("gradio")[0].version
current_pkg_version = (
pkgutil.get_data(__name__, "version.txt").decode("ascii").strip()
)
latest_pkg_version = requests.get(url=PKG_VERSION_URL).json()["version"]
if StrictVersion(latest_pkg_version) > StrictVersion(current_pkg_version):
print(
@ -49,10 +52,6 @@ def version_check():
)
)
print("--------")
except pkg_resources.DistributionNotFound:
warnings.warn(
"gradio is not setup or installed properly. Unable to get version info."
)
except json.decoder.JSONDecodeError:
warnings.warn("unable to parse version details from package URL.")
except KeyError:

View File

@ -37,18 +37,6 @@ os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
class TestUtils(unittest.TestCase):
@mock.patch("pkg_resources.require")
def test_should_fail_with_distribution_not_found(self, mock_require):
mock_require.side_effect = pkg_resources.DistributionNotFound()
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
version_check()
self.assertEqual(
str(w[-1].message),
"gradio is not setup or installed properly. Unable to get version info.",
)
@mock.patch("requests.get")
def test_should_warn_with_unable_to_parse(self, mock_get):
mock_get.side_effect = json.decoder.JSONDecodeError("Expecting value", "", 0)