Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit57eaea1

Browse files
committed
Added PostgresNode.__repr__() method and fix doctests
1 parent1289214 commit57eaea1

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

‎testgres/api.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@
77
edit configuration files, start/stop cluster, execute queries. The
88
typical flow may look like:
99
10-
>>> with get_new_node() as node:
10+
>>> with get_new_node('test') as node:
1111
... node.init().start()
1212
... result = node.safe_psql('postgres', 'select 1')
1313
... print(result.decode('utf-8').strip())
1414
... node.stop()
15-
<testgres.node.PostgresNode object at 0x...>
15+
PostgresNode('test', port=..., base_dir=...)
1616
1
17-
<testgres.node.PostgresNode object at 0x...>
17+
PostgresNode('test', port=..., base_dir=...)
1818
1919
Or:
2020
21-
>>> with get_new_node() as master:
21+
>>> with get_new_node('master') as master:
2222
... master.init().start()
2323
... with master.backup() as backup:
24-
... with backup.spawn_replica() as replica:
24+
... with backup.spawn_replica('replica') as replica:
2525
... replica = replica.start()
2626
... master.execute('postgres', 'create table test (val int4)')
2727
... master.execute('postgres', 'insert into test values (0), (1), (2)')
2828
... replica.catchup() # wait until changes are visible
2929
... print(replica.execute('postgres', 'select count(*) from test'))
30-
<testgres.node.PostgresNode object at 0x...>
30+
PostgresNode('master', port=..., base_dir=...)
3131
[(3,)]
3232
3333
Copyright (c) 2016, Postgres Professional

‎testgres/config.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ def scoped_config(**options):
152152
Temporarily set custom GlobalConfig options for this context.
153153
154154
Example:
155+
>>> from .api import get_new_node
155156
>>> with scoped_config(cache_initdb=False):
156157
... with get_new_node().init().start() as node:
157158
... print(node.execute('select 1'))
159+
[(1,)]
158160
"""
159161

160162
try:

‎testgres/node.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ def __exit__(self, type, value, traceback):
135135
else:
136136
self._try_shutdown(attempts)
137137

138+
def__repr__(self):
139+
return"PostgresNode('{}', port={}, base_dir={})".format(
140+
self.name,self.port,self.base_dir)
141+
138142
@property
139143
defpid(self):
140144
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp