use pytest tmpdir fixture instead of making our own temp file

This commit is contained in:
codl 2017-11-27 17:43:37 +01:00
pare 80b1ce61c9
commit 14a34396e5
No se encontró ninguna clave conocida en la base de datos para esta firma
ID de clave GPG: 6CD7C8891ED1233A

Veure arxiu

@ -26,15 +26,10 @@ def test_create_app(mocker, to_file=None, redirect_uris=None, website=None):
assert app == ('foo', 'bar') assert app == ('foo', 'bar')
assert requests.post.called assert requests.post.called
def test_create_app_to_file(mocker): def test_create_app_to_file(mocker, tmpdir):
import tempfile, os filepath = tmpdir.join('credentials')
(fd, filename) = tempfile.mkstemp(text=True) test_create_app(mocker, to_file=str(filepath))
assert filepath.read_text('UTF-8') == "foo\nbar\n"
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_redirect_uris(mocker): def test_create_app_redirect_uris(mocker):
test_create_app(mocker, redirect_uris='http://example.net') test_create_app(mocker, redirect_uris='http://example.net')