From 4cb7216a253280b770b86ba97a9dc9f885d12526 Mon Sep 17 00:00:00 2001 From: tekendratimsina <60095381+tekendratimsina@users.noreply.github.com> Date: Wed, 29 Jun 2022 21:51:50 +0300 Subject: [PATCH] removing old redundant code that yields SettingWithCopyWarning, remove depracated inplace, and fix hanging tests (#88) * removing old redundant code that is causing SettingWithCopyWarning * fix conftest that was using different oauth2 flow --- gspread_pandas/util.py | 9 +-------- tests/conf_test.py | 6 +++--- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/gspread_pandas/util.py b/gspread_pandas/util.py index 86fd8b4..27bd873 100644 --- a/gspread_pandas/util.py +++ b/gspread_pandas/util.py @@ -1,5 +1,4 @@ import warnings -from distutils.version import StrictVersion from re import match from time import sleep @@ -217,13 +216,7 @@ def fillna(df, fill_value=""): """ for col in df.dtypes[df.dtypes == "category"].index: if fill_value not in df[col].cat.categories: - df[col].cat.add_categories([fill_value], inplace=True) - # Known bug https://github.com/pandas-dev/pandas/issues/25472 - if StrictVersion(pd.__version__) >= StrictVersion("1.0"): - for col in df.dtypes[ - df.dtypes.apply(lambda x: x in ["float64", "int16"]) - ].index: - df[col] = df[col].astype("float") + df[col] = df[col].cat.add_categories([fill_value]) return df.fillna(fill_value) diff --git a/tests/conf_test.py b/tests/conf_test.py index e9bfab7..b876696 100644 --- a/tests/conf_test.py +++ b/tests/conf_test.py @@ -45,7 +45,7 @@ def test_oauth_no_key(self, set_oauth_config): conf.get_creds(user=None) def test_oauth_first_time(self, mocker, set_oauth_config, creds_json): - mocked = mocker.patch.object(conf.InstalledAppFlow, "run_console") + mocked = mocker.patch.object(conf.InstalledAppFlow, "run_local_server") mocked.return_value = OAuth2Credentials.from_authorized_user_info(creds_json) conf.get_creds() # python 3.5 doesn't have assert_called_once @@ -53,10 +53,10 @@ def test_oauth_first_time(self, mocker, set_oauth_config, creds_json): assert (conf.get_config_dir() / "creds" / "default").exists() def test_oauth_first_time_no_save(self, mocker, set_oauth_config): - mocker.patch.object(conf.InstalledAppFlow, "run_console") + mocker.patch.object(conf.InstalledAppFlow, "run_local_server") conf.get_creds(save=False) # python 3.5 doesn't have assert_called_once - assert conf.InstalledAppFlow.run_console.call_count == 1 + assert conf.InstalledAppFlow.run_local_server.call_count == 1 def test_oauth_default(self, make_creds): assert isinstance(conf.get_creds(), OAuth2Credentials)