tests: add context managers required by python3 (#60657)
This commit is contained in:
parent
9723596999
commit
01c0e80fc0
|
@ -444,8 +444,6 @@ def test_concurrent_put(app, transactional_db, settings):
|
|||
response = app.put_json(url, params=payload)
|
||||
assert response.status_code == 201
|
||||
|
||||
pool = ThreadPool(pool_count)
|
||||
|
||||
def f(i):
|
||||
from django.db import connection
|
||||
if i % 2 == 0:
|
||||
|
@ -455,6 +453,8 @@ def test_concurrent_put(app, transactional_db, settings):
|
|||
connection.close()
|
||||
return i
|
||||
|
||||
results = pool.map(f, range(put_count))
|
||||
with ThreadPool(pool_count) as pool:
|
||||
results = pool.map(f, range(put_count))
|
||||
|
||||
assert len(results) == put_count
|
||||
assert sum(len(files) for _, _, files in os.walk(settings.MEDIA_ROOT)) == 1
|
||||
|
|
|
@ -18,7 +18,8 @@ def get_tests_file(filename):
|
|||
|
||||
|
||||
def get_tests_file_content(filename):
|
||||
return open(get_tests_file(filename), 'rb').read()
|
||||
with open(get_tests_file(filename), 'rb') as fd:
|
||||
return fd.read()
|
||||
|
||||
|
||||
def create_service(name, password=None):
|
||||
|
|
Loading…
Reference in New Issue