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

Commit56ddf77

Browse files
committed
Merge branch 'master' of github.com:postgrespro/testgres
2 parents5a81db1 +7d724ac commit56ddf77

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

‎testgres/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
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(name='...', port=..., base_dir='...')
1616
1
17-
<testgres.node.PostgresNode object at 0x...>
17+
PostgresNode(name='...', port=..., base_dir='...')
1818
1919
Or:
2020
@@ -27,7 +27,7 @@
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(name='...', 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
@@ -139,6 +139,10 @@ def __exit__(self, type, value, traceback):
139139
else:
140140
self._try_shutdown(attempts)
141141

142+
def__repr__(self):
143+
return"{}(name='{}', port={}, base_dir='{}')".format(
144+
self.__class__.__name__,self.name,self.port,self.base_dir)
145+
142146
@property
143147
defpid(self):
144148
"""

‎tests/test_simple.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# coding: utf-8
33

44
importos
5+
importre
56
importsubprocess
67
importtempfile
78
importtestgres
@@ -70,6 +71,11 @@ def removing(f):
7071

7172

7273
classTestgresTests(unittest.TestCase):
74+
deftest_node_repr(self):
75+
withget_new_node()asnode:
76+
pattern='PostgresNode\(name=\'.+\', port=.+, base_dir=\'.+\'\)'
77+
self.assertIsNotNone(re.match(pattern,str(node)))
78+
7379
deftest_custom_init(self):
7480
withget_new_node()asnode:
7581
# enable page checksums

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp