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 fromall commits
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
6 changes: 3 additions & 3 deletionstestgres/api.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,9 +12,9 @@
... result = node.safe_psql('postgres', 'select 1')
... print(result.decode('utf-8').strip())
... node.stop()
<testgres.node.PostgresNode object at 0x...>
PostgresNode(name='...', port=..., base_dir='...')
1
<testgres.node.PostgresNode object at 0x...>
PostgresNode(name='...', port=..., base_dir='...')

Or:

Expand All@@ -27,7 +27,7 @@
... 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'))
<testgres.node.PostgresNode object at 0x...>
PostgresNode(name='...', port=..., base_dir='...')
[(3,)]

Copyright (c) 2016, Postgres Professional
Expand Down
2 changes: 2 additions & 0 deletionstestgres/config.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -152,9 +152,11 @@ def scoped_config(**options):
Temporarily set custom GlobalConfig options for this context.

Example:
>>> from .api import get_new_node
>>> with scoped_config(cache_initdb=False):
... with get_new_node().init().start() as node:
... print(node.execute('select 1'))
[(1,)]
"""

try:
Expand Down
4 changes: 4 additions & 0 deletionstestgres/node.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -135,6 +135,10 @@ def __exit__(self, type, value, traceback):
else:
self._try_shutdown(attempts)

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

@property
def pid(self):
"""
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