Use with to open files to avoid keeping them open in case of errors
This commit is contained in:
parent
a71e82c315
commit
e9beeb85fc
1 changed files with 6 additions and 6 deletions
|
@ -231,12 +231,12 @@ class TestContent:
|
|||
def testVerifyUnsafePattern(self, site):
|
||||
site.content_manager.contents["content.json"]["includes"]["data/test_include/content.json"]["files_allowed"] = "([a-zA-Z]+)*"
|
||||
with pytest.raises(UnsafePatternError) as err:
|
||||
data = site.storage.open("data/test_include/content.json")
|
||||
site.content_manager.verifyFile("data/test_include/content.json", data, ignore_same=False)
|
||||
assert "Potentially unsafe" in str(err)
|
||||
with site.storage.open("data/test_include/content.json") as data:
|
||||
site.content_manager.verifyFile("data/test_include/content.json", data, ignore_same=False)
|
||||
assert "Potentially unsafe" in str(err)
|
||||
|
||||
site.content_manager.contents["data/users/content.json"]["user_contents"]["permission_rules"]["([a-zA-Z]+)*"] = {"max_size": 0}
|
||||
with pytest.raises(UnsafePatternError) as err:
|
||||
data = site.storage.open("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json")
|
||||
site.content_manager.verifyFile("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json", data, ignore_same=False)
|
||||
assert "Potentially unsafe" in str(err)
|
||||
with site.storage.open("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json") as data:
|
||||
site.content_manager.verifyFile("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json", data, ignore_same=False)
|
||||
assert "Potentially unsafe" in str(err)
|
||||
|
|
Loading…
Reference in a new issue