Skip to content

Add version property to PostgresNode #49

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions testgres/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,16 @@ def utils_log_file(self):
def pg_log_file(self):
return os.path.join(self.logs_dir, PG_LOG_FILE)

@property
def version(self):
"""
Return PostgreSQL version for this node.

Returns:
Instance of :class:`distutils.version.LooseVersion`.
"""
return self._pg_version

def _try_shutdown(self, max_attempts):
attempts = 0

Expand Down
7 changes: 7 additions & 0 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import tempfile
import testgres
import time
import six
import unittest

import logging.config
Expand Down Expand Up @@ -857,6 +858,12 @@ def test_version_management(self):
self.assertTrue(b > c)
self.assertTrue(a > c)

version = get_pg_version()
with get_new_node() as node:
self.assertTrue(isinstance(version, six.string_types))
self.assertTrue(isinstance(node.version, PgVer))
self.assertEqual(node.version, str(version))

def test_child_pids(self):
master_processes = [
ProcessType.AutovacuumLauncher,
Expand Down