add unit tests to show, that encoding parameter in open_resource method is necessary
This commit is contained in:
parent
66af0e55ef
commit
8249bc1ed4
1 changed files with 13 additions and 0 deletions
|
|
@ -341,6 +341,19 @@ class TestHelpers:
|
||||||
with app.open_resource("static/index.html", mode) as f:
|
with app.open_resource("static/index.html", mode) as f:
|
||||||
assert "<h1>Hello World!</h1>" in str(f.read())
|
assert "<h1>Hello World!</h1>" in str(f.read())
|
||||||
|
|
||||||
|
@pytest.mark.skip(reason="this feature is not yet implemented")
|
||||||
|
@pytest.mark.parametrize("encoding", ("utf-8", 'utf-16-le'))
|
||||||
|
def test_open_resource_with_encoding(self, encoding):
|
||||||
|
app = flask.Flask(__name__)
|
||||||
|
if os.path.isfile('tests/static/test.txt'):
|
||||||
|
os.remove('tests/static/test.txt')
|
||||||
|
|
||||||
|
with open('tests/static/test.txt', 'w', encoding=encoding) as f:
|
||||||
|
f.write(u'' + 'Hello World!')
|
||||||
|
|
||||||
|
with app.open_resource("static/test.txt", mode='r', encoding=encoding) as f:
|
||||||
|
assert "Hello World!" in f.read()
|
||||||
|
|
||||||
@pytest.mark.parametrize("mode", ("w", "x", "a", "r+"))
|
@pytest.mark.parametrize("mode", ("w", "x", "a", "r+"))
|
||||||
def test_open_resource_exceptions(self, mode):
|
def test_open_resource_exceptions(self, mode):
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue