Skip to content

Commit

Permalink
removing old redundant code that yields SettingWithCopyWarning, remov…
Browse files Browse the repository at this point in the history
…e depracated inplace, and fix hanging tests (#88)

* removing old redundant code that is causing SettingWithCopyWarning

* fix conftest that was using different oauth2 flow
  • Loading branch information
tekendratimsina authored Jun 29, 2022
1 parent da38bc4 commit 4cb7216
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
9 changes: 1 addition & 8 deletions gspread_pandas/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import warnings
from distutils.version import StrictVersion
from re import match
from time import sleep

Expand Down Expand Up @@ -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)


Expand Down
6 changes: 3 additions & 3 deletions tests/conf_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ 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
assert mocked.call_count == 1
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)
Expand Down

0 comments on commit 4cb7216

Please sign in to comment.