File: Refactor-test_create_pkcs11-for-future-compat.patch

package info (click to toggle)
barbican 1%3A20.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 4,472 kB
  • sloc: python: 41,218; sh: 911; makefile: 80
file content (39 lines) | stat: -rw-r--r-- 1,662 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Description: Refactor test_create_pkcs11 for future compat
 The test_create_pkcs11 fails under Python 3.13 due to an
 extra call in the mock_calls list for mocked open:
 .
  call('seed_file', 'rb'),
  call().__enter__(),
  call().read(32),
  call().__exit__(None, None, None),
  call().close() << additional call under Python 3.13
 .
 Refactor to check that a read with the correct seed length
 occured rather than checking the full call list for better
 general compatibility with future Pythons; the general
 handling in the open context manager is not really pertinent
 to the test so no value is lost.
Author: James Page <james.page@canonical.com>
Date: Thu, 16 Jan 2025 08:41:36 +0000
Change-Id: Id45a391b798ca0b21a200055f07a44a937fc6b89
Origin: upstream, https://review.opendev.org/c/openstack/barbican/+/939419
Last-Update: 2025-05-13

diff --git a/barbican/tests/plugin/crypto/test_p11_crypto.py b/barbican/tests/plugin/crypto/test_p11_crypto.py
index 3ee1fd3..b0d418e 100644
--- a/barbican/tests/plugin/crypto/test_p11_crypto.py
+++ b/barbican/tests/plugin/crypto/test_p11_crypto.py
@@ -331,11 +331,8 @@
 
         self.assertIsInstance(p11, pkcs11.PKCS11)
         mo.assert_called_once_with('seed_file', 'rb')
-        calls = [mock.call('seed_file', 'rb'),
-                 mock.call().__enter__(),
-                 mock.call().read(32),
-                 mock.call().__exit__(None, None, None)]
-        self.assertEqual(mo.mock_calls, calls)
+        handle = mo()
+        handle.read.assert_called_once_with(32)
         lib.C_SeedRandom.assert_called_once_with(mock.ANY, mock.ANY, 32)
         self.cfg_mock.p11_crypto_plugin.seed_file = ''