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

Commit008236d

Browse files
committed
Added test for PostgresNode.__repr__() method; removed node name from examples
1 parent57eaea1 commit008236d

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
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('test') as node:
10+
>>> with get_new_node() 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-
PostgresNode('test', port=..., base_dir=...)
15+
PostgresNode(name='...', port=..., base_dir='...')
1616
1
17-
PostgresNode('test', port=..., base_dir=...)
17+
PostgresNode(name='...', port=..., base_dir='...')
1818
1919
Or:
2020
21-
>>> with get_new_node('master') as master:
21+
>>> with get_new_node() as master:
2222
... master.init().start()
2323
... with master.backup() as backup:
24-
... with backup.spawn_replica('replica') as replica:
24+
... with backup.spawn_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-
PostgresNode('master', port=..., base_dir=...)
30+
PostgresNode(name='...', port=..., base_dir='...')
3131
[(3,)]
3232
3333
Copyright (c) 2016, Postgres Professional

‎testgres/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def __exit__(self, type, value, traceback):
136136
self._try_shutdown(attempts)
137137

138138
def__repr__(self):
139-
return"PostgresNode('{}', port={}, base_dir={})".format(
139+
return"PostgresNode(name='{}', port={}, base_dir='{}')".format(
140140
self.name,self.port,self.base_dir)
141141

142142
@property

‎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