Mercurial > p > roundup > code
diff test/test_security.py @ 7167:f6b24a8524cd
Modify code to reduce runtime when testing
The prior change to set default number of PBKDF2 rounds to 2000000
(2M) raised runtime in CI from 12 minutes to an hour.
This commit checks to see if we are invoked from a pytest test using:
if ("pytest" in sys.modules and
"PYTEST_CURRENT_TEST" in os.environ):
when no config object is present. I assume that the number of times we
have a full config object is less than with a missing config object.
See if this brings CI runtimes back down. It reduces runtimes on my
local box, but....
Code adapted from
https://stackoverflow.com/questions/25188119/test-if-code-is-executed-from-within-a-py-test-session/44595269#
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 25 Feb 2023 14:50:34 -0500 |
| parents | 970cd6d2b8ea |
| children | 8b2287d850c8 |
line wrap: on
line diff
--- a/test/test_security.py Fri Feb 24 23:47:28 2023 -0500 +++ b/test/test_security.py Sat Feb 25 14:50:34 2023 -0500 @@ -432,4 +432,15 @@ self.assertEqual(p.needs_migration(config=self.db.config), True) + def test_encodePasswordNoConfig(self): + # should run cleanly as we are in a test. + # + p = roundup.password.encodePassword('sekrit', 'PBKDF2') + + del(os.environ["PYTEST_CURRENT_TEST"]) + self.assertNotIn("PYTEST_CURRENT_TEST", os.environ) + + with self.assertRaises(roundup.password.ConfigNotSet) as ctx: + roundup.password.encodePassword('sekrit', 'PBKDF2') + # vim: set filetype=python sts=4 sw=4 et si :
