integration tests: persist pdb history between test runs

Run pytest --pdb. On failure or breakpoint, it will fall back to PDB. Commands written here will be saved to a local file and loaded at the start of the next test run.
This commit is contained in:
Nikita Fomichev 2024-03-25 18:39:27 +01:00
parent 5cd2d26781
commit e98d6fd24c
2 changed files with 31 additions and 0 deletions

3
.gitignore vendored
View File

@ -164,6 +164,9 @@ tests/queries/0_stateless/*.generated-expect
tests/queries/0_stateless/*.expect.history
tests/integration/**/_gen
# pytest --pdb history
.pdb_history
# rust
/rust/**/target*
# It is autogenerated from *.in

View File

@ -13,6 +13,34 @@ from helpers.network import _NetworkManager
logging.raiseExceptions = False
@pytest.fixture(scope="session", autouse=True)
def pdb_history(request):
"""
Fixture loads and saves pdb history to file, so it can be preserved between runs
"""
if request.config.getoption("--pdb"):
import readline # pylint:disable=import-outside-toplevel
import pdb # pylint:disable=import-outside-toplevel
def save_history():
readline.write_history_file(".pdb_history")
def load_history():
try:
readline.read_history_file(".pdb_history")
except FileNotFoundError:
pass
load_history()
pdb.Pdb.use_rawinput = True
yield
save_history()
else:
yield
@pytest.fixture(autouse=True, scope="session")
def tune_local_port_range():
# Lots of services uses non privileged ports: