+
+
+def test_cursor_scalar_no_rows(db, table_factory):
+ table_factory('dummy')
+
+ with db.cursor() as cur:
+ with pytest.raises(RuntimeError):
+ cur.scalar('SELECT id FROM dummy')
+
+
+def test_get_pg_env_add_variable(monkeypatch):
+ monkeypatch.delenv('PGPASSWORD', raising=False)
+ env = get_pg_env('user=fooF')
+
+ assert env['PGUSER'] == 'fooF'
+ assert 'PGPASSWORD' not in env
+
+
+def test_get_pg_env_overwrite_variable(monkeypatch):
+ monkeypatch.setenv('PGUSER', 'some default')
+ env = get_pg_env('user=overwriter')
+
+ assert env['PGUSER'] == 'overwriter'
+
+
+def test_get_pg_env_ignore_unknown():
+ env = get_pg_env('tty=stuff', base_env={})
+
+ assert env == {}