diff options
| author | Egor Tensin <egor@tensin.name> | 2026-06-13 17:58:56 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-06-13 17:58:56 +0200 |
| commit | 394e306633a7e8898b8d6d1bee5bd247de6ae705 (patch) | |
| tree | 962a0eb5af3d88d99bd9816e0e9d7de00f0aec9b /test/file.py | |
| parent | use nested namespaces (diff) | |
| download | aes-tools-394e306633a7e8898b8d6d1bee5bd247de6ae705.tar.gz aes-tools-394e306633a7e8898b8d6d1bee5bd247de6ae705.zip | |
workflows/ci: add linting for Python test scripts
Diffstat (limited to 'test/file.py')
| -rwxr-xr-x | test/file.py | 66 |
1 files changed, 42 insertions, 24 deletions
diff --git a/test/file.py b/test/file.py index a2f54d3..6930c8d 100755 --- a/test/file.py +++ b/test/file.py @@ -88,8 +88,9 @@ def _make_output_file(): os.remove(tmp_path) -def run_encryption_test(tools, algorithm, mode, key, plaintext_path, - ciphertext_path, iv=None, force=False): +def run_encryption_test( + tools, algorithm, mode, key, plaintext_path, ciphertext_path, iv=None, force=False +): logging.debug('Running encryption test...') logging.debug('\tPlaintext file path: %s', plaintext_path) logging.debug('\tExpected ciphertext file path: %s', ciphertext_path) @@ -100,8 +101,7 @@ def run_encryption_test(tools, algorithm, mode, key, plaintext_path, logging.debug('\tEncrypted file path: %s', tmp_path) try: - tools.run_encrypt_file(algorithm, mode, key, plaintext_path, - tmp_path, iv) + tools.run_encrypt_file(algorithm, mode, key, plaintext_path, tmp_path, iv) if force: logging.warning('Overwriting expected ciphertext file') shutil.copy(tmp_path, ciphertext_path) @@ -116,8 +116,9 @@ def run_encryption_test(tools, algorithm, mode, key, plaintext_path, return TestExitCode.ERROR -def run_decryption_test(tools, algorithm, mode, key, plaintext_path, - ciphertext_path, iv=None): +def run_decryption_test( + tools, algorithm, mode, key, plaintext_path, ciphertext_path, iv=None +): logging.debug('Running decryption test...') logging.debug('\tCiphertext file path: %s', ciphertext_path) logging.debug('\tExpected plaintext file path: %s', plaintext_path) @@ -128,8 +129,7 @@ def run_decryption_test(tools, algorithm, mode, key, plaintext_path, logging.debug('\tDecrypted file path: %s', tmp_path) try: - tools.run_decrypt_file(algorithm, mode, key, ciphertext_path, - tmp_path, iv) + tools.run_decrypt_file(algorithm, mode, key, ciphertext_path, tmp_path, iv) if filecmp.cmp(tmp_path, plaintext_path): return TestExitCode.SUCCESS logging.error('The decrypted file doesn\'t match the plaintext file') @@ -178,8 +178,8 @@ _script_name = os.path.splitext(os.path.basename(__file__))[0] def _setup_logging(verbose=False): level = logging.DEBUG if verbose else logging.INFO logging.basicConfig( - format='%(asctime)s | %(module)s | %(levelname)s | %(message)s', - level=level) + format='%(asctime)s | %(module)s | %(levelname)s | %(message)s', level=level + ) def run_tests(suite_path, tools_path=(), verbose=False, use_sde=False, force=False): @@ -197,8 +197,10 @@ def run_tests(suite_path, tools_path=(), verbose=False, use_sde=False, force=Fal logging.info('\tSucceeded: %d', exit_codes.count(TestExitCode.SUCCESS)) logging.info('\tFailed: %d', exit_codes.count(TestExitCode.FAILURE)) - if (exit_codes.count(TestExitCode.ERROR) == 0 and - exit_codes.count(TestExitCode.FAILURE) == 0): + if ( + exit_codes.count(TestExitCode.ERROR) == 0 + and exit_codes.count(TestExitCode.FAILURE) == 0 + ): return 0 else: return 1 @@ -208,18 +210,34 @@ def _parse_args(args=None): if args is None: args = sys.argv[1:] parser = argparse.ArgumentParser() - parser.add_argument('--path', '-p', dest='tools_path', metavar='PATH', - nargs='*', - help='set file encryption utilities directory path') - parser.add_argument('--sde', '-e', dest='use_sde', action='store_true', - help='use Intel SDE to run the utilities') - parser.add_argument('--verbose', '-v', action='store_true', - help='verbose log output') - parser.add_argument('--force', '-f', action='store_true', - help='overwrite ciphertext files') - parser.add_argument('--suite', '-s', dest='suite_path', - default=os.path.join(_script_dir, 'data', 'file'), - help='set test suite directory path') + parser.add_argument( + '--path', + '-p', + dest='tools_path', + metavar='PATH', + nargs='*', + help='set file encryption utilities directory path', + ) + parser.add_argument( + '--sde', + '-e', + dest='use_sde', + action='store_true', + help='use Intel SDE to run the utilities', + ) + parser.add_argument( + '--verbose', '-v', action='store_true', help='verbose log output' + ) + parser.add_argument( + '--force', '-f', action='store_true', help='overwrite ciphertext files' + ) + parser.add_argument( + '--suite', + '-s', + dest='suite_path', + default=os.path.join(_script_dir, 'data', 'file'), + help='set test suite directory path', + ) return parser.parse_args(args) |
