clean up open_resource and tests

This commit is contained in:
David Lord 2019-05-17 13:20:31 -07:00
parent ad709be46e
commit 6f703a564c
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
3 changed files with 13 additions and 21 deletions

View file

@ -1062,26 +1062,16 @@ class TestHelpers(object):
assert rv.data == b"Hello"
assert rv.mimetype == "text/html"
@pytest.mark.parametrize('mode', [
'r',
'rb',
'rt'
])
@pytest.mark.parametrize("mode", ("r", "rb", "rt"))
def test_open_resource(self, mode):
app = flask.Flask(__name__)
with app.open_resource('static/index.html', mode) as f:
assert '<h1>Hello World!</h1>' in str(f.read())
@pytest.mark.parametrize('mode', [
'w',
'x',
'a',
'b',
't',
'+'
])
with app.open_resource("static/index.html", mode) as f:
assert "<h1>Hello World!</h1>" in str(f.read())
@pytest.mark.parametrize("mode", ("w", "x", "a", "r+"))
def test_open_resource_exceptions(self, mode):
app = flask.Flask(__name__)
with pytest.raises(ValueError):
app.open_resource('static/index.html', mode)
with pytest.raises(ValueError):
app.open_resource("static/index.html", mode)