test/redis/README.md suggests that when running "pytest" the default is to connect to a local redis on localhost:6379. This default was recently lost when options were added to use a different host and port. It's still good to have the default suggested in README.md. It also makes it easier to run the tests against the standard redis, which by default runs on localhost:6379 - by just running "pytest". Signed-off-by: Nadav Har'El <nyh@scylladb.com> Message-Id: <20200825195143.124429-1-nyh@scylladb.com>
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
# Copyright 2020 ScyllaDB
|
|
#
|
|
# This file is part of Scylla.
|
|
#
|
|
# Scylla is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Scylla is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with Scylla. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# This file contains "test fixtures", a pytest concept described in
|
|
# https://docs.pytest.org/en/latest/fixture.html.
|
|
# A "fixture" is some sort of setup which an invididual test requires to run.
|
|
# The fixture has setup code and teardown code, and if multiple tests
|
|
# require the same fixture, it can be set up only once - while still allowing
|
|
# the user to run individual tests and automatically set up the fixtures they need.
|
|
|
|
import pytest
|
|
|
|
def pytest_addoption(parser):
|
|
parser.addoption("--redis-host", action="store", default="localhost",
|
|
help="ip address")
|
|
parser.addoption("--redis-port", action="store", type=int, default=6379,
|
|
help="port number")
|
|
|
|
|
|
@pytest.fixture
|
|
def redis_host(request):
|
|
return request.config.getoption('--redis-host')
|
|
|
|
@pytest.fixture
|
|
def redis_port(request):
|
|
return request.config.getoption('--redis-port')
|