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

Add PostgresNode.__repr__() method#44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
funbringer merged 3 commits intopostgrespro:masterfromzilder:node_repr
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Added test for PostgresNode.__repr__() method; removed node name from…
… examples
  • Loading branch information
@zilder
zilder committedMar 22, 2018
commit008236d0cb7ce3c24c2c55c86aa9bcc480e7e873
12 changes: 6 additions & 6 deletionstestgres/api.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,27 +7,27 @@
edit configuration files, start/stop cluster, execute queries. The
typical flow may look like:

>>> with get_new_node('test') as node:
>>> with get_new_node() as node:
... node.init().start()
... result = node.safe_psql('postgres', 'select 1')
... print(result.decode('utf-8').strip())
... node.stop()
PostgresNode('test', port=..., base_dir=...)
PostgresNode(name='...', port=..., base_dir='...')
1
PostgresNode('test', port=..., base_dir=...)
PostgresNode(name='...', port=..., base_dir='...')

Or:

>>> with get_new_node('master') as master:
>>> with get_new_node() as master:
... master.init().start()
... with master.backup() as backup:
... with backup.spawn_replica('replica') as replica:
... with backup.spawn_replica() as replica:
... replica = replica.start()
... master.execute('postgres', 'create table test (val int4)')
... master.execute('postgres', 'insert into test values (0), (1), (2)')
... replica.catchup() # wait until changes are visible
... print(replica.execute('postgres', 'select count(*) from test'))
PostgresNode('master', port=..., base_dir=...)
PostgresNode(name='...', port=..., base_dir='...')
[(3,)]

Copyright (c) 2016, Postgres Professional
Expand Down
2 changes: 1 addition & 1 deletiontestgres/node.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -136,7 +136,7 @@ def __exit__(self, type, value, traceback):
self._try_shutdown(attempts)

def __repr__(self):
return "PostgresNode('{}', port={}, base_dir={})".format(
return "PostgresNode(name='{}', port={}, base_dir='{}')".format(
self.name, self.port, self.base_dir)

@property
Expand Down
6 changes: 6 additions & 0 deletionstests/test_simple.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@
# coding: utf-8

import os
import re
import subprocess
import tempfile
import testgres
Expand DownExpand Up@@ -70,6 +71,11 @@ def removing(f):


class TestgresTests(unittest.TestCase):
def test_node_repr(self):
with get_new_node() as node:
pattern = 'PostgresNode\(name=\'.+\', port=.+, base_dir=\'.+\'\)'
self.assertIsNotNone(re.match(pattern, str(node)))

def test_custom_init(self):
with get_new_node() as node:
# enable page checksums
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp