From 3e4185913b584f5cc9a54f16f3c223861e11ec18 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Thu, 16 Apr 2026 17:14:23 +0200 Subject: Introduce a new marco - %e and migrate the project from GitHub to Codeberg --- tests/conftest.py | 30 +++++++++++++++--------------- tests/test_cli.py | 11 +---------- tests/test_envtoolkit_instance.py | 2 +- tests/test_envtoolkit_instance_static.py | 2 +- 4 files changed, 18 insertions(+), 27 deletions(-) (limited to 'tests') diff --git a/tests/conftest.py b/tests/conftest.py index a4463fd..6cc8b9f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,5 @@ # etoolkit -# Copyright (C) 2021-2024 Simeon Simeonov +# Copyright (C) 2021-2026 Simeon Simeonov # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ import json import pytest -@pytest.fixture() +@pytest.fixture def config_data(): """config_data for testing""" @@ -59,7 +59,7 @@ def config_data(): } -@pytest.fixture() +@pytest.fixture def config_file(tmp_path, config_data): """Temporary config file for testing that includes config_data""" @@ -68,7 +68,7 @@ def config_file(tmp_path, config_data): return str(cf) -@pytest.fixture() +@pytest.fixture def long_encrypted_value(): """enc. value corresponding to 'Nobody expects the Spanish inquisition'""" @@ -79,25 +79,25 @@ def long_encrypted_value(): ) -@pytest.fixture() +@pytest.fixture def long_value(): """standard value (> 32 bytes)""" return 'Nobody expects the Spanish inquisition' -@pytest.fixture() +@pytest.fixture def master_password(): """Master passord""" return 'The very secret passwd' -@pytest.fixture() +@pytest.fixture def new_master_password(): """Master passord""" return 'New very secret passwd' -@pytest.fixture() +@pytest.fixture def non_random_bytes_32(): """always use the same bytes instead of os.urandom(32)""" @@ -107,7 +107,7 @@ def non_random_bytes_32(): ) -@pytest.fixture() +@pytest.fixture def non_random_bytes_57(): """always use the same bytes instead of os.urandom(57)""" @@ -118,14 +118,14 @@ def non_random_bytes_57(): ) -@pytest.fixture() +@pytest.fixture def nonexistent_config_file(tmp_path): """temporary config file for testing that includes config_data""" return str(tmp_path / 'etoolkitt.json') -@pytest.fixture() +@pytest.fixture def password_hash(): """password hash for testing, corresponding to 'The very secret passwd'""" @@ -135,7 +135,7 @@ def password_hash(): ) -@pytest.fixture() +@pytest.fixture def short_encrypted_value(): """enc. value corresponding to 'secret1'""" @@ -145,7 +145,7 @@ def short_encrypted_value(): ) -@pytest.fixture() +@pytest.fixture def short_encrypted_value_v1(): """enc. value (enc-val 1) corresponding to 'secret1'""" @@ -155,13 +155,13 @@ def short_encrypted_value_v1(): ) -@pytest.fixture() +@pytest.fixture def short_value(): """standard value (< 32 bytes)""" return 'secret1' -@pytest.fixture() +@pytest.fixture def wrong_master_password(): """Wrong master passord""" return 'the very secret passwd' diff --git a/tests/test_cli.py b/tests/test_cli.py index 953abf4..b7913da 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,5 +1,5 @@ # etoolkit -# Copyright (C) 2021-2024 Simeon Simeonov +# Copyright (C) 2021-2026 Simeon Simeonov # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -38,7 +38,6 @@ def test_decrypt_v1(binput, capsys, config_file, master_password): ): with pytest.raises(SystemExit) as exit_info: main(['-c', f'{config_file}', '-d']) - assert exit_info.type == SystemExit assert exit_info.value.code == 0 assert capsys.readouterr().out.strip() == 'Decrypted value: bar' @@ -60,7 +59,6 @@ def test_decrypt_v2( ): with pytest.raises(SystemExit) as exit_info: main(['-c', f'{config_file}', '-d']) - assert exit_info.type == SystemExit assert exit_info.value.code == 0 assert capsys.readouterr().out.strip() == ( f'Decrypted value: {short_value}' @@ -88,7 +86,6 @@ def test_encrypt_with_echo( ): with pytest.raises(SystemExit) as exit_info: main(['-c', f'{config_file}', '-e', '-E']) - assert exit_info.type == SystemExit assert exit_info.value.code == 0 assert capsys.readouterr().out.strip() == ( f'Encrypted value: {short_encrypted_value}' @@ -116,7 +113,6 @@ def test_encrypt_without_echo( ): with pytest.raises(SystemExit) as exit_info: main(['-c', f'{config_file}', '-e']) - assert exit_info.type == SystemExit assert exit_info.value.code == 0 assert capsys.readouterr().out.strip() == ( f'Encrypted value: {short_encrypted_value}' @@ -139,11 +135,9 @@ def test_list(capsys, config_file, nonexistent_config_file): with pytest.raises(SystemExit) as exit_info: main(['-c', nonexistent_config_file, '-l']) - assert exit_info.type == SystemExit assert exit_info.value.code == errno.EIO with pytest.raises(SystemExit) as exit_info: main(['-c', config_file, '-l']) - assert exit_info.type == SystemExit assert exit_info.value.code == 0 assert capsys.readouterr().out.strip() == f'dev{os.linesep}secret' @@ -153,7 +147,6 @@ def test_help(capsys): with pytest.raises(SystemExit) as exit_info: main(['-h']) - assert exit_info.type == SystemExit assert exit_info.value.code == 0 assert capsys.readouterr().out.startswith('usage: etoolkit') @@ -169,7 +162,6 @@ def test_generate_master_password_hash( urandom.return_value = non_random_bytes_32 with pytest.raises(SystemExit) as exit_info: main(['--generate-master-password-hash']) - assert exit_info.type == SystemExit assert exit_info.value.code == 0 assert capsys.readouterr().out.strip() == ( 'Master password hash: pbkdf2_sha256$500000$uYpZM1VfAGq0CDZL2duITs076' @@ -182,7 +174,6 @@ def test_version(capsys): with pytest.raises(SystemExit) as exit_info: main(['-v']) - assert exit_info.type == SystemExit assert exit_info.value.code == 0 assert capsys.readouterr().out.startswith( f'etoolkit {etoolkit.__version__}' diff --git a/tests/test_envtoolkit_instance.py b/tests/test_envtoolkit_instance.py index f555f81..5137e9f 100644 --- a/tests/test_envtoolkit_instance.py +++ b/tests/test_envtoolkit_instance.py @@ -1,5 +1,5 @@ # etoolkit -# Copyright (C) 2021-2024 Simeon Simeonov +# Copyright (C) 2021-2026 Simeon Simeonov # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_envtoolkit_instance_static.py b/tests/test_envtoolkit_instance_static.py index ee5cf9e..e13d439 100644 --- a/tests/test_envtoolkit_instance_static.py +++ b/tests/test_envtoolkit_instance_static.py @@ -1,5 +1,5 @@ # etoolkit -# Copyright (C) 2021-2024 Simeon Simeonov +# Copyright (C) 2021-2026 Simeon Simeonov # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by -- cgit v1.3