This commit is contained in:
@@ -117,22 +117,10 @@ class TestCase(unittest.TestCase, metaclass=TestCaseMeta):
|
||||
self.__unhandled_exceptions = []
|
||||
|
||||
def tearDown(self):
|
||||
excs = []
|
||||
for exc in self.__unhandled_exceptions:
|
||||
if isinstance(exc, ConnectionResetError):
|
||||
texc = traceback.TracebackException.from_exception(
|
||||
exc, lookup_lines=False)
|
||||
if texc.stack[-1].name == "_call_connection_lost":
|
||||
# On Windows calling socket.shutdown may raise
|
||||
# ConnectionResetError, which happens in the
|
||||
# finally block of _call_connection_lost.
|
||||
continue
|
||||
excs.append(exc)
|
||||
|
||||
if excs:
|
||||
if self.__unhandled_exceptions:
|
||||
formatted = []
|
||||
|
||||
for i, context in enumerate(excs):
|
||||
for i, context in enumerate(self.__unhandled_exceptions):
|
||||
formatted.append(self._format_loop_exception(context, i + 1))
|
||||
|
||||
self.fail(
|
||||
@@ -226,6 +214,13 @@ def _init_cluster(ClusterCls, cluster_kwargs, initdb_options=None):
|
||||
return cluster
|
||||
|
||||
|
||||
def _start_cluster(ClusterCls, cluster_kwargs, server_settings,
|
||||
initdb_options=None):
|
||||
cluster = _init_cluster(ClusterCls, cluster_kwargs, initdb_options)
|
||||
cluster.start(port='dynamic', server_settings=server_settings)
|
||||
return cluster
|
||||
|
||||
|
||||
def _get_initdb_options(initdb_options=None):
|
||||
if not initdb_options:
|
||||
initdb_options = {}
|
||||
@@ -249,12 +244,8 @@ def _init_default_cluster(initdb_options=None):
|
||||
_default_cluster = pg_cluster.RunningCluster()
|
||||
else:
|
||||
_default_cluster = _init_cluster(
|
||||
pg_cluster.TempCluster,
|
||||
cluster_kwargs={
|
||||
"data_dir_suffix": ".apgtest",
|
||||
},
|
||||
initdb_options=_get_initdb_options(initdb_options),
|
||||
)
|
||||
pg_cluster.TempCluster, cluster_kwargs={},
|
||||
initdb_options=_get_initdb_options(initdb_options))
|
||||
|
||||
return _default_cluster
|
||||
|
||||
@@ -271,7 +262,6 @@ def create_pool(dsn=None, *,
|
||||
max_size=10,
|
||||
max_queries=50000,
|
||||
max_inactive_connection_lifetime=60.0,
|
||||
connect=None,
|
||||
setup=None,
|
||||
init=None,
|
||||
loop=None,
|
||||
@@ -281,18 +271,12 @@ def create_pool(dsn=None, *,
|
||||
**connect_kwargs):
|
||||
return pool_class(
|
||||
dsn,
|
||||
min_size=min_size,
|
||||
max_size=max_size,
|
||||
max_queries=max_queries,
|
||||
loop=loop,
|
||||
connect=connect,
|
||||
setup=setup,
|
||||
init=init,
|
||||
min_size=min_size, max_size=max_size,
|
||||
max_queries=max_queries, loop=loop, setup=setup, init=init,
|
||||
max_inactive_connection_lifetime=max_inactive_connection_lifetime,
|
||||
connection_class=connection_class,
|
||||
record_class=record_class,
|
||||
**connect_kwargs,
|
||||
)
|
||||
**connect_kwargs)
|
||||
|
||||
|
||||
class ClusterTestCase(TestCase):
|
||||
|
||||
Reference in New Issue
Block a user