summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIrina Truong <i.chernyavska@gmail.com>2017-08-18 07:38:21 -0700
committerGitHub <noreply@github.com>2017-08-18 07:38:21 -0700
commit386838b31fa4928dbbca8df1330f23df977f9b23 (patch)
tree22d5d41a5291d5326766822e805bd025a51e9acd
parent1e77eab21b8e3b6592007123bf1daec759bdb5e5 (diff)
parent5ab0dbfdea12baeaf8adb648f1558a17cc34a79f (diff)
Merge pull request #781 from dbcli/feature/conftest-getenv
Fix TODO, optionally use POSTGRES_USER, POSTGRES_HOST POSTGRES_PASSWORD from environment
-rw-r--r--changelog.rst1
-rw-r--r--tests/conftest.py4
-rw-r--r--tests/utils.py6
3 files changed, 7 insertions, 4 deletions
diff --git a/changelog.rst b/changelog.rst
index ed0a4990..7eeeefc4 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -16,6 +16,7 @@ Bug Fixes:
* Fix the way we get host when using DSN (issue #765) (Thanks: `François Pietka`_)
* Add missing keyword COLUMN after DROP (issue #769) (Thanks: `François Pietka`_)
* Don't include arguments in function suggestions for backslash commands (Thanks: `Joakim Koljonen`_)
+* Optionally use POSTGRES_USER, POSTGRES_HOST POSTGRES_PASSWORD from environment (Thanks: `Dick Marinus`_)
1.7.0
=====
diff --git a/tests/conftest.py b/tests/conftest.py
index 27a08b08..b9c6c2f2 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,5 +1,5 @@
import pytest
-from utils import (POSTGRES_HOST, POSTGRES_USER, create_db, db_connection,
+from utils import (POSTGRES_HOST, POSTGRES_USER, POSTGRES_PASSWORD, create_db, db_connection,
drop_tables)
import pgcli.pgexecute
@@ -23,7 +23,7 @@ def cursor(connection):
@pytest.fixture
def executor(connection):
return pgcli.pgexecute.PGExecute(database='_test_db', user=POSTGRES_USER,
- host=POSTGRES_HOST, password=None, port=None, dsn=None)
+ host=POSTGRES_HOST, password=POSTGRES_PASSWORD, port=None, dsn=None)
@pytest.fixture
diff --git a/tests/utils.py b/tests/utils.py
index e63e0173..c8cb42bd 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -3,9 +3,11 @@ import psycopg2
import psycopg2.extras
from pgcli.main import format_output, OutputSettings
from pgcli.pgexecute import register_json_typecasters
+from os import getenv
-# TODO: should this be somehow be divined from environment?
-POSTGRES_USER, POSTGRES_HOST = 'postgres', 'localhost'
+POSTGRES_USER = getenv('PGUSER', 'postgres')
+POSTGRES_HOST = getenv('PGHOST', 'localhost')
+POSTGRES_PASSWORD = getenv('PGPASSWORD', '')
def db_connection(dbname=None):