1919
2020from .config import testgres_config
2121
22- from .connection import \
23- NodeConnection , \
24- InternalError , \
25- ProgrammingError
22+ from .connection import NodeConnection
2623
2724from .consts import \
2825 DATA_DIR , \
@@ -531,10 +528,10 @@ def append_conf(self, line='', filename=PG_CONF_FILE, **kwargs):
531528 This instance of :class:`.PostgresNode`.
532529
533530 Examples:
534- append_conf(fsync=False)
535- append_conf('log_connections = yes')
536- append_conf(random_page_cost=1.5, fsync=True, ...)
537- append_conf('postgresql.conf', 'synchronous_commit = off')
531+ >>> append_conf(fsync=False)
532+ >>> append_conf('log_connections = yes')
533+ >>> append_conf(random_page_cost=1.5, fsync=True, ...)
534+ >>> append_conf('postgresql.conf', 'synchronous_commit = off')
538535 """
539536
540537 lines = [line ]
@@ -970,8 +967,7 @@ def poll_query_until(self,
970967 sleep_time = 1 ,
971968 expected = True ,
972969 commit = True ,
973- raise_programming_error = True ,
974- raise_internal_error = True ):
970+ suppress = None ):
975971 """
976972 Run a query once per second until it returns 'expected'.
977973 Query should return a single value (1 row, 1 column).
@@ -984,13 +980,13 @@ def poll_query_until(self,
984980 sleep_time: how much should we sleep after a failure?
985981 expected: what should be returned to break the cycle?
986982 commit: should (possible) changes be committed?
987- raise_programming_error: enable ProgrammingError?
988- raise_internal_error: enable InternalError?
983+ suppress: a collection of exceptions to be suppressed.
989984
990985 Examples:
991- poll_query_until('select true')
992- poll_query_until('postgres', "select now() > '01.01.2018'")
993- poll_query_until('select false', expected=True, max_attempts=4)
986+ >>> poll_query_until('select true')
987+ >>> poll_query_until('postgres', "select now() > '01.01.2018'")
988+ >>> poll_query_until('select false', expected=True, max_attempts=4)
989+ >>> poll_query_until('select 1', suppress={testgres.OperationalError})
994990 """
995991
996992 # sanity checks
@@ -1022,13 +1018,8 @@ def poll_query_until(self,
10221018 elif expected is None :
10231019 return # done
10241020
1025- except ProgrammingError as e :
1026- if raise_programming_error :
1027- raise e
1028-
1029- except InternalError as e :
1030- if raise_internal_error :
1031- raise e
1021+ except tuple (suppress or []):
1022+ pass # we're suppressing them
10321023
10331024 time .sleep (sleep_time )
10341025 attempts += 1
@@ -1219,13 +1210,14 @@ def pgbench_run(self, dbname=None, username=None, options=[], **kwargs):
12191210 options: additional options for pgbench (list).
12201211
12211212 **kwargs: named options for pgbench.
1222- Examples:
1223- pgbench_run(initialize=True, scale=2)
1224- pgbench_run(time=10)
12251213 Run pgbench --help to learn more.
12261214
12271215 Returns:
12281216 Stdout produced by pgbench.
1217+
1218+ Examples:
1219+ >>> pgbench_run(initialize=True, scale=2)
1220+ >>> pgbench_run(time=10)
12291221 """
12301222
12311223 # Set default arguments
0 commit comments