SaashaJoshi/piQture

Unit test for `qcnn` fails with update in Python version to 3.12

Closed this issue · 1 comments

Python 3.12 doesn't accept the called_once_with() method.

layer_instance_called_once = any(
layer_mock.called_once_with(
num_qubits=num_qubits, circuit=mock.ANY, unmeasured_bits=mock.ANY
)
for layer_name, layer_mock in mock_layers.items()
)

Refer #50

While mocking instantiation of any method or class, one must also specify the return value. This was missing from the earlier versions of the test_qcnn.py file.

Another important note, while mocking classes that are only instantiated, one needs to mock the __init__ method.