From 7fd7db9cd12d59f7c523dc2a1a167f7445e5b2f3 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Mon, 4 May 2026 18:38:58 +0200 Subject: Add support for the %e{key} format and add support for type checkers (ty) --- tests/conftest.py | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'tests/conftest.py') diff --git a/tests/conftest.py b/tests/conftest.py index 6cc8b9f..2e8eaf1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,14 +16,14 @@ """Common fixtures""" import json +import pathlib import pytest @pytest.fixture -def config_data(): +def config_data() -> dict: """config_data for testing""" - return { 'general': { 'MASTER_PASSWORD_HASH': ( @@ -60,18 +60,16 @@ def config_data(): @pytest.fixture -def config_file(tmp_path, config_data): +def config_file(tmp_path: pathlib.Path, config_data: dict) -> str: """Temporary config file for testing that includes config_data""" - cf = tmp_path / 'etoolkit.json' cf.write_text(json.dumps(config_data)) return str(cf) @pytest.fixture -def long_encrypted_value(): +def long_encrypted_value() -> str: """enc. value corresponding to 'Nobody expects the Spanish inquisition'""" - return ( 'enc-val$2$uYpZM1VfAGq0CDZL2duITs076CQj+hIFEgx+F4mn80o=$' 'UWP5YeRsh5/2vZ2J1UOS+BJti73Kbp6C1pJmCo8hF' @@ -80,27 +78,26 @@ def long_encrypted_value(): @pytest.fixture -def long_value(): +def long_value() -> str: """standard value (> 32 bytes)""" return 'Nobody expects the Spanish inquisition' @pytest.fixture -def master_password(): +def master_password() -> str: """Master passord""" return 'The very secret passwd' @pytest.fixture -def new_master_password(): +def new_master_password() -> str: """Master passord""" return 'New very secret passwd' @pytest.fixture -def non_random_bytes_32(): +def non_random_bytes_32() -> bytes: """always use the same bytes instead of os.urandom(32)""" - return ( b'\xb9\x8aY3U_\x00j\xb4\x086K\xd9\xdb\x88N' b'\xcd;\xe8$#\xfa\x12\x05\x12\x0c~\x17\x89\xa7\xf3J' @@ -108,9 +105,8 @@ def non_random_bytes_32(): @pytest.fixture -def non_random_bytes_57(): +def non_random_bytes_57() -> bytes: """always use the same bytes instead of os.urandom(57)""" - return ( b'D$\x99\xaa\xafiZ\xb4C\xa0%XTz)\xca\xedK\xcd\xa2F~\xff+\xa1[\xe2\xaa' b'\xb2\xd3\x07\x13\xedb\xc2\x84\xfe\tS\r\xf0\x02_\xef\xe3\xde\xf1?e' @@ -119,16 +115,14 @@ def non_random_bytes_57(): @pytest.fixture -def nonexistent_config_file(tmp_path): +def nonexistent_config_file(tmp_path: pathlib.Path) -> str: """temporary config file for testing that includes config_data""" - return str(tmp_path / 'etoolkitt.json') @pytest.fixture -def password_hash(): +def password_hash() -> str: """password hash for testing, corresponding to 'The very secret passwd'""" - return ( 'pbkdf2_sha256$500000$UY3o78KUM1Btzxk3k3JCsijnwtJ2lx+hH9NewpVKxo8=$' 'tHwDm8OVKanC4DoYTigTCb0R3lQIa/CbBYj0B3TZtHg=' @@ -136,9 +130,8 @@ def password_hash(): @pytest.fixture -def short_encrypted_value(): +def short_encrypted_value() -> str: """enc. value corresponding to 'secret1'""" - return ( 'enc-val$2$RCSZqq9pWrRDoCVYVHopyu1LzaJGfv8roVviqrLTBxM=$' '+YYrZbwTBuG0Pl+WMQrvxLUtq5j8qYuQqzoIwgoGt7AaWZCJz+E7qoDeg3wke70ST8U=' @@ -146,9 +139,8 @@ def short_encrypted_value(): @pytest.fixture -def short_encrypted_value_v1(): +def short_encrypted_value_v1() -> str: """enc. value (enc-val 1) corresponding to 'secret1'""" - return ( 'enc-val$1$/cXpEMoZrTlb9yokGhw8tLTSUkqnqJ4ZoAkurNgMYx' 'w=$1VdkSMcZnLRwLiu1M8VlYcbelwmiVNY=' @@ -156,12 +148,12 @@ def short_encrypted_value_v1(): @pytest.fixture -def short_value(): +def short_value() -> str: """standard value (< 32 bytes)""" return 'secret1' @pytest.fixture -def wrong_master_password(): +def wrong_master_password() -> str: """Wrong master passord""" return 'the very secret passwd' -- cgit v1.3