Skip to content

Commit 84af299

Browse files
volodymyrssbsipocz
authored andcommitted
use text, maybe helps with windows condition
1 parent f73ad59 commit 84af299

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

astroquery/heasarc/tests/parametrization.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818

1919
class MockResponse:
20-
def __init__(self, content):
21-
self.content = content
22-
self.text = content.decode()
20+
def __init__(self, text):
21+
self.text = text
22+
self.content = text.encode()
2323

2424

2525
def data_path(filename, output=False):
@@ -44,7 +44,7 @@ def get_mockreturn(session, method, url, params=None, timeout=10, **kwargs):
4444

4545
filename = filename_for_request(url, params)
4646
try:
47-
content = open(filename, "rb").read()
47+
content = open(filename, "rt").read()
4848
except FileNotFoundError:
4949
log.error(
5050
f"no stored mock data in {filename} for url=\"{url}\" and params=\"{params}\""
@@ -58,20 +58,20 @@ def get_mockreturn(session, method, url, params=None, timeout=10, **kwargs):
5858

5959
def save_response_of_get(session, method, url, params=None, timeout=10, **kwargs):
6060

61-
content = requests.Session._original_request(
61+
text = requests.Session._original_request(
6262
session, method, url, params=params, timeout=timeout
63-
).content
63+
).text
6464

6565
filename = filename_for_request(url, params, output=True)
6666

67-
with open(filename, "wb") as f:
67+
with open(filename, "wt") as f:
6868
log.info(f"saving output to {filename} for url=\"{url}\" and params=\"{params}\"")
6969
log.warning(
7070
f"you may want to run `cp -fv {os.path.dirname(filename)}/* astroquery/heasarc/tests/data/; rm -rfv build`"
7171
)
72-
f.write(content)
72+
f.write(text)
7373

74-
return MockResponse(content)
74+
return MockResponse(text)
7575

7676

7777
@pytest.fixture(autouse=True)

0 commit comments

Comments
 (0)