forked from orbit-oss/flask
clean up open_resource and tests
This commit is contained in:
parent
ad709be46e
commit
6f703a564c
3 changed files with 13 additions and 21 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue