Skip to content
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
1 change: 1 addition & 0 deletions newsfragments/1115.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix an issue where number of search counts has been hard-default set to 5 by command-line default and ini setting could not override it.
3 changes: 2 additions & 1 deletion pytest_postgresql/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def get_postgresql_option(option: str) -> Any:
exec=get_postgresql_option("exec"),
host=get_postgresql_option("host"),
port=get_postgresql_option("port"),
port_search_count=get_postgresql_option("port_search_count"),
# Parse as int, because if it's defined in an INI file then it'll always be a string
port_search_count=int(get_postgresql_option("port_search_count")),
user=get_postgresql_option("user"),
password=get_postgresql_option("password"),
options=get_postgresql_option("options"),
Expand Down
2 changes: 1 addition & 1 deletion pytest_postgresql/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with pytest-postgresql. If not, see <http://www.gnu.org/licenses/>.
"""Plugin module of pytest-postgresql."""

from tempfile import gettempdir

from _pytest.config.argparsing import Parser
Expand Down Expand Up @@ -92,7 +93,6 @@ def pytest_addoption(parser: Parser) -> None:
action="store",
dest="postgresql_port_search_count",
help=_help_port_search_count,
default=5,
)

parser.addoption("--postgresql-user", action="store", dest="postgresql_user", help=_help_user)
Expand Down
14 changes: 14 additions & 0 deletions tests/examples/test_assert_port_search_count_is_ten.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Asserts that port_search_count is 10.

That shows that it is not the default (5), and that we parsed it as an integer.
"""

from pytest import FixtureRequest

from pytest_postgresql.config import get_config


def test_assert_port_search_count_is_ten(request: FixtureRequest) -> None:
"""Asserts that port_search_count is 10."""
config = get_config(request)
assert config["port_search_count"] == 10
17 changes: 17 additions & 0 deletions tests/test_postgres_options_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ def test_postgres_loader_in_ini(pointed_pytester: Pytester) -> None:
ret.assert_outcomes(passed=1)


def test_postgres_port_search_count_in_cli_is_int(pointed_pytester: Pytester) -> None:
"""Check that the --postgresql-port-search-count command line argument is parsed as an int."""
pointed_pytester.copy_example("test_assert_port_search_count_is_ten.py")
ret = pointed_pytester.runpytest(
"--postgresql-port-search-count", "10", "test_assert_port_search_count_is_ten.py"
)
ret.assert_outcomes(passed=1)


def test_postgres_port_search_count_in_ini_is_int(pointed_pytester: Pytester) -> None:
"""Check that pytest.ini arguments are honored for load."""
pointed_pytester.copy_example("test_assert_port_search_count_is_ten.py")
pointed_pytester.makefile(".ini", pytest="[pytest]\npostgresql_port_search_count = 10\n")
ret = pointed_pytester.runpytest("test_assert_port_search_count_is_ten.py")
ret.assert_outcomes(passed=1)


postgresql_proc_to_override = postgresql_proc()


Expand Down
Loading