From 14a34396e59cba365de1e53b43ddc0aaf59d191b Mon Sep 17 00:00:00 2001 From: codl Date: Mon, 27 Nov 2017 17:43:37 +0100 Subject: [PATCH] use pytest tmpdir fixture instead of making our own temp file --- tests/test_create_app.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/test_create_app.py b/tests/test_create_app.py index 5777caa..8745b47 100644 --- a/tests/test_create_app.py +++ b/tests/test_create_app.py @@ -26,15 +26,10 @@ def test_create_app(mocker, to_file=None, redirect_uris=None, website=None): assert app == ('foo', 'bar') assert requests.post.called -def test_create_app_to_file(mocker): - import tempfile, os - (fd, filename) = tempfile.mkstemp(text=True) - - test_create_app(mocker, to_file=filename) - with os.fdopen(fd) as f: - assert f.read() == "foo\nbar\n" - - os.remove(filename) +def test_create_app_to_file(mocker, tmpdir): + filepath = tmpdir.join('credentials') + test_create_app(mocker, to_file=str(filepath)) + assert filepath.read_text('UTF-8') == "foo\nbar\n" def test_create_app_redirect_uris(mocker): test_create_app(mocker, redirect_uris='http://example.net')