From d4f186078c7f19866a28ba132b89cf4e3fb84d08 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Fri, 29 Jan 2021 19:57:14 +0100 Subject: [PATCH] During tests we can run with lowest rounds (#45710) --- tests/conftest.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index f6ef33e8f25..6e3edbd73e8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -98,6 +98,21 @@ def verify_cleanup(): assert not threads +@pytest.fixture(autouse=True) +def bcrypt_cost(): + """Run with reduced rounds during tests, to speed up uses.""" + import bcrypt + + gensalt_orig = bcrypt.gensalt + + def gensalt_mock(rounds=12, prefix=b"2b"): + return gensalt_orig(4, prefix) + + bcrypt.gensalt = gensalt_mock + yield + bcrypt.gensalt = gensalt_orig + + @pytest.fixture def hass_storage(): """Fixture to mock storage."""