Skip to content

Commit

Permalink
py<311 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
ocefpaf committed Jun 19, 2024
1 parent a2e4e45 commit c220e8b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions tests/test_config_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def setUp(self):
foo: [1, null]
"""
self.handle, self.yamlfile = tempfile.mkstemp(suffix=".yaml")
with Path.open(self.yamlfile, "w") as f:
with Path(self.yamlfile).open("w") as f:
f.write(template)

self.expected_dict = {
Expand All @@ -51,21 +51,21 @@ def setUp(self):

def tearDown(self):
os.close(self.handle)
Path.unlink(self.yamlfile)
Path(self.yamlfile).unlink()

def test_load_yaml_dict_object(self):
with Path.open(self.yamlfile) as f:
with Path(self.yamlfile).open() as f:
y = yaml.load(f.read())
qc = QcConfig(y)
assert qc.config == self.expected_dict

def test_load_yaml_str(self):
with Path.open(self.yamlfile) as f:
with Path(self.yamlfile).open() as f:
qc = QcConfig(f.read())
assert qc.config == self.expected_dict

def test_load_json_str(self):
with Path.open(self.yamlfile) as f:
with Path(self.yamlfile).open() as f:
js = json.dumps(yaml.load(f.read()))
qc = QcConfig(js)
assert qc.config == self.expected_dict
Expand All @@ -81,7 +81,7 @@ def test_load_yaml_path_object(self):
def test_load_json_stringio(self):
st = io.StringIO()
qc = QcConfig(self.yamlfile)
with Path.open(self.yamlfile) as f:
with Path(self.yamlfile).open() as f:
js = json.dumps(yaml.load(f.read()))
st.write(js)
qc = QcConfig(st)
Expand All @@ -90,7 +90,7 @@ def test_load_json_stringio(self):

def test_load_yaml_stringio(self):
st = io.StringIO()
with Path.open(self.yamlfile) as f:
with Path(self.yamlfile).open() as f:
st.write(f.read())
qc = QcConfig(st)
st.close()
Expand Down Expand Up @@ -294,12 +294,13 @@ def setUp(self):
period: month
"""
self.handle, self.yamlfile = tempfile.mkstemp(suffix=".yaml")
with Path.open(self.yamlfile, "w") as f:
p = Path(self.yamlfile)
with p.open("w") as f:
f.write(template)

def tearDown(self):
os.close(self.handle)
Path.unlink(self.yamlfile)
Path(self.yamlfile).unlink()

def test_climatology_config_yaml_conversion(self):
qc = QcConfig(self.yamlfile)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_qartod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2051,7 +2051,7 @@ def test_density_inversion_input(self):
depth = [1, 2, 3]

match = (
"ufunc 'less' did not contain a loop with signature matching types"
"'less'|<"
)
# Wrong type suspect_threshold
with pytest.raises(TypeError, match=match):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def setUp(self):

def tearDown(self):
os.close(self.fh)
Path.unlink(self.fp)
Path(self.fp).unlink()

def test_load_from_xarray_file(self):
c = utils.load_config_as_dict(self.fp)
Expand Down

0 comments on commit c220e8b

Please sign in to comment.