use tmp_path instead of tmpdir

This commit is contained in:
David Lord 2023-05-02 10:38:27 -07:00
parent 1d7281fe07
commit 0a00e1b608
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
4 changed files with 59 additions and 64 deletions

View file

@ -1,6 +1,5 @@
import json
import os
import textwrap
import pytest
@ -242,17 +241,10 @@ def test_get_namespace():
@pytest.mark.parametrize("encoding", ["utf-8", "iso-8859-15", "latin-1"])
def test_from_pyfile_weird_encoding(tmpdir, encoding):
f = tmpdir.join("my_config.py")
f.write_binary(
textwrap.dedent(
f"""
# -*- coding: {encoding} -*-
TEST_VALUE = "föö"
"""
).encode(encoding)
)
def test_from_pyfile_weird_encoding(tmp_path, encoding):
f = tmp_path / "my_config.py"
f.write_text(f'# -*- coding: {encoding} -*-\nTEST_VALUE = "föö"\n', encoding)
app = flask.Flask(__name__)
app.config.from_pyfile(str(f))
app.config.from_pyfile(os.fspath(f))
value = app.config["TEST_VALUE"]
assert value == "föö"