Skip to content

Commit

Permalink
Deepcopy to apis (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
MtkN1 committed Mar 31, 2022
1 parent 228f7f6 commit 474a0bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pybotters/client.py
@@ -1,5 +1,6 @@
from __future__ import annotations

import copy
import json
import logging
import os
Expand Down Expand Up @@ -226,7 +227,7 @@ def _load_apis(
apis = {}
if isinstance(apis, dict):
if apis:
return apis
return copy.deepcopy(apis)
else:
current_apis = os.path.join(os.getcwd(), "apis.json")
if os.path.isfile(current_apis):
Expand All @@ -238,7 +239,7 @@ def _load_apis(
with open(env_apis) as fp:
return json.load(fp)
else:
return apis
return copy.deepcopy(apis)
elif isinstance(apis, str):
with open(apis) as fp:
return json.load(fp)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_client.py
Expand Up @@ -25,6 +25,9 @@ async def test_client():
"name2": tuple(["key2", "secret2".encode()]),
"name3": tuple(["key3", "secret3".encode()]),
}
assert [tuple(x) for x in apis.values()] != [
x for x in client._session.__dict__["_apis"].values()
]


async def test_client_open(mocker: pytest_mock.MockerFixture):
Expand Down

0 comments on commit 474a0bb

Please sign in to comment.