From fcf94c603288eb60dd787ac9730a7ff2a57ea1f4 Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Tue, 10 Oct 2023 14:06:19 +0200 Subject: [PATCH 01/15] remove qiskit.test --- qiskit/test/__init__.py | 18 - qiskit/test/_canonical.py | 125 ------- qiskit/test/base.py | 343 ------------------ qiskit/test/decorators.py | 308 ---------------- qiskit/test/ibmq_mock.py | 45 --- qiskit/test/mock/__init__.py | 40 -- qiskit/test/mock/backends/__init__.py | 32 -- qiskit/test/mock/backends/almaden/__init__.py | 32 -- qiskit/test/mock/backends/armonk/__init__.py | 32 -- qiskit/test/mock/backends/athens/__init__.py | 32 -- qiskit/test/mock/backends/belem/__init__.py | 32 -- .../test/mock/backends/boeblingen/__init__.py | 32 -- qiskit/test/mock/backends/bogota/__init__.py | 32 -- .../test/mock/backends/brooklyn/__init__.py | 32 -- .../test/mock/backends/burlington/__init__.py | 32 -- qiskit/test/mock/backends/cairo/__init__.py | 32 -- .../test/mock/backends/cambridge/__init__.py | 32 -- .../test/mock/backends/casablanca/__init__.py | 32 -- qiskit/test/mock/backends/essex/__init__.py | 32 -- .../test/mock/backends/guadalupe/__init__.py | 32 -- qiskit/test/mock/backends/hanoi/__init__.py | 32 -- qiskit/test/mock/backends/jakarta/__init__.py | 32 -- .../mock/backends/johannesburg/__init__.py | 32 -- qiskit/test/mock/backends/kolkata/__init__.py | 32 -- qiskit/test/mock/backends/lagos/__init__.py | 32 -- qiskit/test/mock/backends/lima/__init__.py | 32 -- qiskit/test/mock/backends/london/__init__.py | 32 -- .../test/mock/backends/manhattan/__init__.py | 32 -- qiskit/test/mock/backends/manila/__init__.py | 32 -- .../test/mock/backends/melbourne/__init__.py | 32 -- .../test/mock/backends/montreal/__init__.py | 32 -- qiskit/test/mock/backends/mumbai/__init__.py | 32 -- qiskit/test/mock/backends/nairobi/__init__.py | 32 -- qiskit/test/mock/backends/ourense/__init__.py | 32 -- qiskit/test/mock/backends/paris/__init__.py | 32 -- .../mock/backends/poughkeepsie/__init__.py | 32 -- qiskit/test/mock/backends/quito/__init__.py | 32 -- .../test/mock/backends/rochester/__init__.py | 32 -- qiskit/test/mock/backends/rome/__init__.py | 32 -- .../mock/backends/rueschlikon/__init__.py | 32 -- .../test/mock/backends/santiago/__init__.py | 32 -- .../test/mock/backends/singapore/__init__.py | 32 -- qiskit/test/mock/backends/sydney/__init__.py | 32 -- .../test/mock/backends/tenerife/__init__.py | 32 -- qiskit/test/mock/backends/tokyo/__init__.py | 32 -- qiskit/test/mock/backends/toronto/__init__.py | 32 -- .../test/mock/backends/valencia/__init__.py | 32 -- qiskit/test/mock/backends/vigo/__init__.py | 32 -- .../test/mock/backends/washington/__init__.py | 32 -- .../test/mock/backends/yorktown/__init__.py | 32 -- qiskit/test/providers/__init__.py | 16 - qiskit/test/providers/backend.py | 75 ---- qiskit/test/providers/provider.py | 59 --- qiskit/test/reference_circuits.py | 41 --- qiskit/test/testing_options.py | 93 ----- qiskit/test/utils.py | 87 ----- test/__init__.py | 2 +- .../python/algorithms/algorithms_test_case.py | 2 +- .../gradients/test_estimator_gradient.py | 2 +- test/python/algorithms/gradients/test_qfi.py | 2 +- test/python/algorithms/gradients/test_qgt.py | 2 +- .../gradients/test_sampler_gradient.py | 2 +- .../test_compute_uncompute.py | 2 +- .../algorithms/time_evolvers/test_pvqd.py | 2 +- .../basicaer/test_basicaer_integration.py | 2 +- .../basicaer/test_basicaer_qobj_headers.py | 2 +- .../test_multi_registers_convention.py | 3 +- .../classical/test_expr_constructors.py | 2 +- .../circuit/classical/test_expr_helpers.py | 2 +- .../circuit/classical/test_expr_properties.py | 2 +- .../circuit/classical/test_types_ordering.py | 2 +- .../circuit/library/test_evolution_gate.py | 2 +- .../circuit/library/test_evolved_op_ansatz.py | 2 +- .../circuit/library/test_linear_function.py | 2 +- .../circuit/library/test_qaoa_ansatz.py | 2 +- .../circuit/library/test_state_preparation.py | 2 +- test/python/circuit/test_bit.py | 2 +- test/python/circuit/test_calibrations.py | 2 +- test/python/circuit/test_circuit_data.py | 2 +- test/python/circuit/test_circuit_find_bit.py | 2 +- .../circuit/test_circuit_load_from_qpy.py | 2 +- .../circuit/test_circuit_multi_registers.py | 2 +- .../python/circuit/test_circuit_operations.py | 2 +- .../python/circuit/test_circuit_properties.py | 2 +- test/python/circuit/test_circuit_qasm.py | 2 +- test/python/circuit/test_circuit_registers.py | 2 +- .../circuit/test_commutation_checker.py | 2 +- test/python/circuit/test_compose.py | 2 +- test/python/circuit/test_control_flow.py | 2 +- .../circuit/test_control_flow_builders.py | 2 +- test/python/circuit/test_controlled_gate.py | 2 +- test/python/circuit/test_diagonal_gate.py | 2 +- test/python/circuit/test_equivalence.py | 2 +- .../circuit/test_extensions_standard.py | 2 +- test/python/circuit/test_gate_definitions.py | 2 +- test/python/circuit/test_gate_power.py | 2 +- test/python/circuit/test_hamiltonian_gate.py | 2 +- .../circuit/test_identifiers_circuits.py | 2 +- test/python/circuit/test_initializer.py | 2 +- .../python/circuit/test_instruction_repeat.py | 2 +- test/python/circuit/test_instructions.py | 2 +- test/python/circuit/test_isometry.py | 2 +- test/python/circuit/test_operation.py | 2 +- test/python/circuit/test_parameters.py | 2 +- test/python/circuit/test_random_circuit.py | 2 +- test/python/circuit/test_register.py | 2 +- .../circuit/test_registerless_circuit.py | 2 +- test/python/circuit/test_squ.py | 2 +- test/python/circuit/test_templates.py | 2 +- test/python/circuit/test_tensor.py | 2 +- test/python/circuit/test_tools.py | 2 +- test/python/circuit/test_uc.py | 2 +- test/python/circuit/test_ucx_y_z.py | 2 +- test/python/circuit/test_unitary.py | 2 +- .../test_classical_function.py | 2 +- .../classical_function_compiler/test_parse.py | 2 +- .../test_simulate.py | 2 +- .../test_synthesis.py | 2 +- .../test_tweedledum2qiskit.py | 2 +- .../test_typecheck.py | 2 +- .../classical_function_compiler/test_utils.py | 2 +- test/python/compiler/test_assembler.py | 2 +- test/python/compiler/test_compiler.py | 2 +- test/python/compiler/test_disassembler.py | 2 +- test/python/compiler/test_scheduler.py | 2 +- test/python/compiler/test_sequencer.py | 2 +- test/python/compiler/test_transpiler.py | 2 +- test/python/converters/test_ast_to_dag.py | 2 +- test/python/converters/test_circuit_to_dag.py | 2 +- .../test_circuit_to_dagdependency.py | 2 +- .../python/converters/test_circuit_to_gate.py | 2 +- .../converters/test_circuit_to_instruction.py | 2 +- .../converters/test_dag_to_dagdependency.py | 2 +- test/python/dagcircuit/test_collect_blocks.py | 2 +- test/python/dagcircuit/test_compose.py | 2 +- test/python/dagcircuit/test_dagcircuit.py | 2 +- test/python/dagcircuit/test_dagdependency.py | 2 +- .../mock/test_mock_module_deprecation.py | 2 +- test/python/opflow/opflow_test_case.py | 2 +- .../primitives/test_backend_estimator.py | 2 +- .../python/primitives/test_backend_sampler.py | 2 +- test/python/primitives/test_estimator.py | 2 +- test/python/primitives/test_primitive.py | 2 +- test/python/primitives/test_result.py | 2 +- test/python/primitives/test_sampler.py | 2 +- test/python/primitives/test_utils.py | 2 +- .../test_configurable_backend.py | 2 +- .../fake_provider/test_fake_backends.py | 2 +- .../providers/test_backendconfiguration.py | 2 +- .../providers/test_backendproperties.py | 2 +- test/python/providers/test_backendstatus.py | 2 +- test/python/providers/test_faulty_backend.py | 2 +- test/python/providers/test_options.py | 2 +- test/python/providers/test_pulse_defaults.py | 2 +- test/python/pulse/test_block.py | 2 +- test/python/pulse/test_builder.py | 2 +- test/python/pulse/test_builder_v2.py | 2 +- test/python/pulse/test_calibration_entries.py | 2 +- test/python/pulse/test_channels.py | 2 +- test/python/pulse/test_continuous_pulses.py | 2 +- test/python/pulse/test_discrete_pulses.py | 2 +- .../pulse/test_experiment_configurations.py | 2 +- .../pulse/test_instruction_schedule_map.py | 2 +- test/python/pulse/test_instructions.py | 2 +- test/python/pulse/test_macros.py | 2 +- test/python/pulse/test_parameter_manager.py | 2 +- test/python/pulse/test_parser.py | 2 +- test/python/pulse/test_pulse_lib.py | 2 +- test/python/pulse/test_reference.py | 2 +- test/python/pulse/test_samplers.py | 2 +- test/python/pulse/test_schedule.py | 2 +- test/python/pulse/test_transforms.py | 2 +- test/python/qasm2/test_arxiv_examples.py | 2 +- test/python/qasm2/test_circuit_methods.py | 2 +- test/python/qasm2/test_export.py | 2 +- test/python/qasm2/test_expression.py | 2 +- test/python/qasm2/test_legacy_importer.py | 2 +- test/python/qasm2/test_lexer.py | 2 +- test/python/qasm2/test_parse_errors.py | 2 +- test/python/qasm2/test_structure.py | 2 +- test/python/qasm3/test_export.py | 2 +- test/python/qasm3/test_import.py | 2 +- test/python/qobj/test_pulse_converter.py | 2 +- test/python/qobj/test_qobj.py | 2 +- test/python/qobj/test_qobj_identifiers.py | 2 +- test/python/qpy/test_block_load_from_qpy.py | 2 +- test/python/qpy/test_circuit_load_from_qpy.py | 2 +- .../operators/symplectic/test_clifford.py | 2 +- .../operators/symplectic/test_pauli.py | 2 +- .../operators/symplectic/test_pauli_list.py | 2 +- .../operators/symplectic/test_pauli_table.py | 2 +- .../operators/symplectic/test_pauli_utils.py | 2 +- .../symplectic/test_sparse_pauli_op.py | 2 +- .../symplectic/test_stabilizer_table.py | 2 +- .../quantum_info/operators/test_measures.py | 2 +- .../quantum_info/operators/test_operator.py | 2 +- .../quantum_info/operators/test_random.py | 2 +- .../quantum_info/operators/test_scalar_op.py | 2 +- .../quantum_info/operators/test_utils.py | 2 +- .../quantum_info/states/test_densitymatrix.py | 2 +- .../quantum_info/states/test_measures.py | 2 +- .../python/quantum_info/states/test_random.py | 2 +- .../states/test_stabilizerstate.py | 2 +- .../quantum_info/states/test_statevector.py | 2 +- test/python/quantum_info/states/test_utils.py | 2 +- test/python/quantum_info/test_analyzation.py | 2 +- .../quantum_info/test_local_invariance.py | 2 +- test/python/quantum_info/test_quaternions.py | 2 +- .../quantum_info/test_sparse_z2_symmetries.py | 2 +- test/python/quantum_info/test_synthesis.py | 2 +- test/python/quantum_info/test_weyl.py | 2 +- .../result/test_memory_marginalization.py | 2 +- test/python/result/test_mitigators.py | 2 +- test/python/result/test_probability.py | 2 +- test/python/result/test_quasi.py | 2 +- test/python/result/test_result.py | 2 +- test/python/result/test_sampled_expval.py | 2 +- test/python/scheduler/test_basic_scheduler.py | 2 +- .../test_clifford_decompose_layers.py | 2 +- .../synthesis/test_cnot_phase_synthesis.py | 2 +- test/python/synthesis/test_cx_cz_synthesis.py | 2 +- test/python/synthesis/test_cz_synthesis.py | 2 +- .../python/synthesis/test_linear_synthesis.py | 2 +- .../synthesis/test_permutation_synthesis.py | 2 +- .../synthesis/test_stabilizer_synthesis.py | 2 +- test/python/test_examples.py | 2 +- test/python/test_qasm_parser.py | 2 +- test/python/test_user_config.py | 2 +- test/python/test_util.py | 2 +- test/python/test_version.py | 2 +- .../tools/monitor/test_backend_monitor.py | 2 +- test/python/tools/monitor/test_job_monitor.py | 2 +- test/python/tools/test_parallel.py | 2 +- test/python/tools/test_pubsub.py | 2 +- .../aqc/fast_gradient/test_cmp_gradients.py | 2 +- .../aqc/fast_gradient/test_layer1q.py | 2 +- .../aqc/fast_gradient/test_layer2q.py | 2 +- .../aqc/fast_gradient/test_utils.py | 2 +- test/python/transpiler/aqc/test_aqc.py | 2 +- test/python/transpiler/aqc/test_aqc_plugin.py | 2 +- .../transpiler/aqc/test_cnot_networks.py | 2 +- test/python/transpiler/aqc/test_gradient.py | 2 +- .../test_instruction_alignments.py | 2 +- .../legacy_scheduling/test_scheduling_pass.py | 2 +- test/python/transpiler/test_1q.py | 2 +- .../transpiler/test_adjacent_barriers.py | 2 +- test/python/transpiler/test_apply_layout.py | 2 +- .../test_barrier_before_final_measurements.py | 2 +- test/python/transpiler/test_basic_swap.py | 2 +- .../transpiler/test_basis_translator.py | 2 +- .../transpiler/test_calibrationbuilder.py | 2 +- .../transpiler/test_check_gate_direction.py | 2 +- test/python/transpiler/test_check_map.py | 2 +- .../python/transpiler/test_clifford_passes.py | 2 +- .../transpiler/test_collect_2q_blocks.py | 2 +- .../transpiler/test_collect_multiq_blocks.py | 2 +- .../transpiler/test_commutation_analysis.py | 2 +- .../test_commutative_cancellation.py | 2 +- .../test_commutative_inverse_cancellation.py | 2 +- .../transpiler/test_consolidate_blocks.py | 2 +- .../transpiler/test_containsinstruction.py | 2 +- .../test_convert_conditions_to_if_ops.py | 2 +- .../test_count_ops_longest_path_pass.py | 2 +- test/python/transpiler/test_count_ops_pass.py | 2 +- test/python/transpiler/test_coupling.py | 2 +- .../test_crosstalk_adaptive_scheduler.py | 2 +- test/python/transpiler/test_csp_layout.py | 2 +- .../python/transpiler/test_cx_cancellation.py | 2 +- .../transpiler/test_dag_fixed_point_pass.py | 2 +- .../transpiler/test_dag_longest_path_pass.py | 2 +- test/python/transpiler/test_decompose.py | 2 +- test/python/transpiler/test_dense_layout.py | 2 +- test/python/transpiler/test_depth_pass.py | 2 +- .../transpiler/test_dynamical_decoupling.py | 2 +- .../test_echo_rzx_weyl_decomposition.py | 2 +- .../test_enlarge_with_ancilla_pass.py | 2 +- test/python/transpiler/test_error.py | 2 +- .../transpiler/test_fixed_point_pass.py | 2 +- .../test_full_ancilla_allocation.py | 2 +- test/python/transpiler/test_gate_direction.py | 2 +- .../transpiler/test_gates_in_basis_pass.py | 2 +- test/python/transpiler/test_generic_pass.py | 2 +- .../transpiler/test_high_level_synthesis.py | 2 +- test/python/transpiler/test_hoare_opt.py | 2 +- .../transpiler/test_instruction_alignments.py | 2 +- .../transpiler/test_inverse_cancellation.py | 2 +- .../transpiler/test_kak_over_optimization.py | 2 +- test/python/transpiler/test_layout.py | 2 +- test/python/transpiler/test_layout_score.py | 2 +- .../transpiler/test_layout_transformation.py | 2 +- .../test_linear_functions_passes.py | 2 +- test/python/transpiler/test_lookahead_swap.py | 2 +- test/python/transpiler/test_mappers.py | 2 +- test/python/transpiler/test_minimum_point.py | 2 +- .../test_naming_transpiled_circuits.py | 2 +- .../transpiler/test_noise_adaptive_layout.py | 2 +- .../test_optimize_1q_commutation.py | 2 +- .../test_optimize_1q_decomposition.py | 2 +- .../transpiler/test_optimize_1q_gates.py | 2 +- .../test_optimize_swap_before_measure.py | 2 +- .../test_parameterizedgate_translator.py | 2 +- test/python/transpiler/test_pass_call.py | 2 +- test/python/transpiler/test_pass_scheduler.py | 2 +- test/python/transpiler/test_passmanager.py | 2 +- .../transpiler/test_passmanager_config.py | 4 +- .../python/transpiler/test_passmanager_run.py | 2 +- .../transpiler/test_preset_passmanagers.py | 2 +- test/python/transpiler/test_property_set.py | 2 +- .../python/transpiler/test_pulse_gate_pass.py | 2 +- .../python/transpiler/test_remove_barriers.py | 2 +- ...st_remove_diagonal_gates_before_measure.py | 2 +- .../test_remove_final_measurements.py | 2 +- .../test_remove_reset_in_zero_state.py | 2 +- ...test_reset_after_measure_simplification.py | 2 +- .../test_resource_estimation_pass.py | 2 +- test/python/transpiler/test_sabre_layout.py | 2 +- test/python/transpiler/test_sabre_swap.py | 2 +- .../test_scheduling_padding_pass.py | 2 +- test/python/transpiler/test_setlayout.py | 2 +- test/python/transpiler/test_size_pass.py | 2 +- test/python/transpiler/test_solovay_kitaev.py | 2 +- test/python/transpiler/test_stage_plugin.py | 2 +- .../transpiler/test_staged_passmanager.py | 2 +- .../python/transpiler/test_stochastic_swap.py | 2 +- test/python/transpiler/test_swap_strategy.py | 2 +- .../transpiler/test_swap_strategy_router.py | 2 +- test/python/transpiler/test_target.py | 2 +- .../transpiler/test_template_matching.py | 2 +- .../transpiler/test_tensor_factor_pass.py | 2 +- test/python/transpiler/test_token_swapper.py | 2 +- .../transpiler/test_transpile_layout.py | 2 +- test/python/transpiler/test_trivial_layout.py | 2 +- .../transpiler/test_unitary_synthesis.py | 2 +- .../test_unitary_synthesis_plugin.py | 2 +- .../transpiler/test_unroll_3q_or_more.py | 2 +- .../test_unroll_custom_definitions.py | 2 +- .../python/transpiler/test_unroll_forloops.py | 2 +- test/python/transpiler/test_unroller.py | 2 +- test/python/transpiler/test_vf2_layout.py | 2 +- .../python/transpiler/test_vf2_post_layout.py | 2 +- test/python/transpiler/test_width_pass.py | 2 +- test/python/utils/mitigation/test_meas.py | 2 +- test/python/utils/test_classtools.py | 2 +- test/python/utils/test_deprecation.py | 2 +- test/python/utils/test_lazy_loaders.py | 2 +- test/python/utils/test_units.py | 2 +- .../visualization/pulse_v2/test_core.py | 2 +- .../visualization/pulse_v2/test_drawings.py | 2 +- .../visualization/pulse_v2/test_events.py | 2 +- .../visualization/pulse_v2/test_generators.py | 2 +- .../visualization/pulse_v2/test_layouts.py | 2 +- .../visualization/test_circuit_drawer.py | 2 +- .../visualization/test_circuit_text_drawer.py | 2 +- .../visualization/test_state_plot_tools.py | 2 +- test/python/visualization/test_utils.py | 2 +- .../visualization/timeline/test_core.py | 2 +- .../visualization/timeline/test_drawings.py | 2 +- .../visualization/timeline/test_generators.py | 2 +- .../visualization/timeline/test_layouts.py | 2 +- test/python/visualization/visualization.py | 2 +- .../circuit/test_circuit_matplotlib_drawer.py | 2 +- .../mpl/graph/test_graph_matplotlib_drawer.py | 2 +- 362 files changed, 307 insertions(+), 2966 deletions(-) delete mode 100644 qiskit/test/__init__.py delete mode 100644 qiskit/test/_canonical.py delete mode 100644 qiskit/test/base.py delete mode 100644 qiskit/test/decorators.py delete mode 100644 qiskit/test/ibmq_mock.py delete mode 100644 qiskit/test/mock/__init__.py delete mode 100644 qiskit/test/mock/backends/__init__.py delete mode 100644 qiskit/test/mock/backends/almaden/__init__.py delete mode 100644 qiskit/test/mock/backends/armonk/__init__.py delete mode 100644 qiskit/test/mock/backends/athens/__init__.py delete mode 100644 qiskit/test/mock/backends/belem/__init__.py delete mode 100644 qiskit/test/mock/backends/boeblingen/__init__.py delete mode 100644 qiskit/test/mock/backends/bogota/__init__.py delete mode 100644 qiskit/test/mock/backends/brooklyn/__init__.py delete mode 100644 qiskit/test/mock/backends/burlington/__init__.py delete mode 100644 qiskit/test/mock/backends/cairo/__init__.py delete mode 100644 qiskit/test/mock/backends/cambridge/__init__.py delete mode 100644 qiskit/test/mock/backends/casablanca/__init__.py delete mode 100644 qiskit/test/mock/backends/essex/__init__.py delete mode 100644 qiskit/test/mock/backends/guadalupe/__init__.py delete mode 100644 qiskit/test/mock/backends/hanoi/__init__.py delete mode 100644 qiskit/test/mock/backends/jakarta/__init__.py delete mode 100644 qiskit/test/mock/backends/johannesburg/__init__.py delete mode 100644 qiskit/test/mock/backends/kolkata/__init__.py delete mode 100644 qiskit/test/mock/backends/lagos/__init__.py delete mode 100644 qiskit/test/mock/backends/lima/__init__.py delete mode 100644 qiskit/test/mock/backends/london/__init__.py delete mode 100644 qiskit/test/mock/backends/manhattan/__init__.py delete mode 100644 qiskit/test/mock/backends/manila/__init__.py delete mode 100644 qiskit/test/mock/backends/melbourne/__init__.py delete mode 100644 qiskit/test/mock/backends/montreal/__init__.py delete mode 100644 qiskit/test/mock/backends/mumbai/__init__.py delete mode 100644 qiskit/test/mock/backends/nairobi/__init__.py delete mode 100644 qiskit/test/mock/backends/ourense/__init__.py delete mode 100644 qiskit/test/mock/backends/paris/__init__.py delete mode 100644 qiskit/test/mock/backends/poughkeepsie/__init__.py delete mode 100644 qiskit/test/mock/backends/quito/__init__.py delete mode 100644 qiskit/test/mock/backends/rochester/__init__.py delete mode 100644 qiskit/test/mock/backends/rome/__init__.py delete mode 100644 qiskit/test/mock/backends/rueschlikon/__init__.py delete mode 100644 qiskit/test/mock/backends/santiago/__init__.py delete mode 100644 qiskit/test/mock/backends/singapore/__init__.py delete mode 100644 qiskit/test/mock/backends/sydney/__init__.py delete mode 100644 qiskit/test/mock/backends/tenerife/__init__.py delete mode 100644 qiskit/test/mock/backends/tokyo/__init__.py delete mode 100644 qiskit/test/mock/backends/toronto/__init__.py delete mode 100644 qiskit/test/mock/backends/valencia/__init__.py delete mode 100644 qiskit/test/mock/backends/vigo/__init__.py delete mode 100644 qiskit/test/mock/backends/washington/__init__.py delete mode 100644 qiskit/test/mock/backends/yorktown/__init__.py delete mode 100644 qiskit/test/providers/__init__.py delete mode 100644 qiskit/test/providers/backend.py delete mode 100644 qiskit/test/providers/provider.py delete mode 100644 qiskit/test/reference_circuits.py delete mode 100644 qiskit/test/testing_options.py delete mode 100644 qiskit/test/utils.py diff --git a/qiskit/test/__init__.py b/qiskit/test/__init__.py deleted file mode 100644 index 362eea2ba0ee..000000000000 --- a/qiskit/test/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Functionality and helpers for testing Qiskit.""" - -from .base import QiskitTestCase -from .decorators import requires_aer_provider, online_test, slow_test -from .reference_circuits import ReferenceCircuits -from .utils import Path diff --git a/qiskit/test/_canonical.py b/qiskit/test/_canonical.py deleted file mode 100644 index 367281f512c9..000000000000 --- a/qiskit/test/_canonical.py +++ /dev/null @@ -1,125 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Utility methods for canonicalising various Qiskit objects, to help with testing.""" - -import threading - -from qiskit.circuit import ( - BreakLoopOp, - CircuitInstruction, - ContinueLoopOp, - ControlFlowOp, - ForLoopOp, - Parameter, - QuantumCircuit, -) - - -class _CanonicalParametersIterator: - """An object that, when iterated through, will produce the same sequence of parameters as every - other instance of this iterator.""" - - __parameters = [] - __mutex = threading.Lock() - - def __init__(self): - self._counter = 0 - - def __iter__(self): - return self - - def __next__(self): - with self.__mutex: - if len(self.__parameters) >= self._counter: - param = Parameter(f"_canonicalization_loop_{self._counter}") - self.__parameters.append(param) - out = self.__parameters[self._counter] - self._counter += 1 - return out - - -def canonicalize_control_flow(circuit: QuantumCircuit) -> QuantumCircuit: - """Canonicalize all control-flow operations in a circuit. - - This is not an efficient operation, and does not affect any properties of the circuit. Its - intent is to normalise parts of circuits that have a non-deterministic construction. These are - the ordering of bit arguments in control-flow blocks output by the builder interface, and - automatically generated ``for``-loop variables. - - The canonical form sorts the bits in the arguments of these operations so that they always - appear in the order they were originally added to the outer-most circuit. For-loop variables - are re-bound into new, cached auto-generated ones.""" - params = iter(_CanonicalParametersIterator()) - base_bit_order = {bit: i for i, bit in enumerate(circuit.qubits)} - base_bit_order.update((bit, i) for i, bit in enumerate(circuit.clbits)) - - def worker(circuit, bit_map=None): - if bit_map is None: - bit_map = {bit: bit for bits in (circuit.qubits, circuit.clbits) for bit in bits} - - def bit_key(bit): - return base_bit_order[bit_map[bit]] - - # This isn't quite QuantumCircuit.copy_empty_like because of the bit reordering. - out = QuantumCircuit( - sorted(circuit.qubits, key=bit_key), - sorted(circuit.clbits, key=bit_key), - *circuit.qregs, - *circuit.cregs, - name=circuit.name, - global_phase=circuit.global_phase, - metadata=circuit.metadata, - ) - for instruction in circuit.data: - new_instruction = instruction - # Control-flow operations associated bits in the instruction arguments with bits in the - # circuit blocks just by sequencing. All blocks must have the same width. - if isinstance(new_instruction.operation, ControlFlowOp): - op = new_instruction.operation - first_block = op.blocks[0] - inner_bit_map = dict( - zip(first_block.qubits, (bit_map[bit] for bit in new_instruction.qubits)) - ) - inner_bit_map.update( - zip(first_block.clbits, (bit_map[bit] for bit in new_instruction.clbits)) - ) - new_instruction = CircuitInstruction( - operation=op.replace_blocks( - [worker(block, inner_bit_map) for block in op.blocks] - ), - qubits=sorted(new_instruction.qubits, key=bit_key), - clbits=sorted(new_instruction.clbits, key=bit_key), - ) - elif isinstance(new_instruction.operation, (BreakLoopOp, ContinueLoopOp)): - new_instruction = new_instruction.replace( - qubits=sorted(new_instruction.qubits, key=bit_key), - clbits=sorted(new_instruction.clbits, key=bit_key), - ) - # For for loops specifically, the control-flow builders generate a loop parameter if one - # is needed but not explicitly supplied. We want the parameters to compare equal, so we - # replace them with those from a shared list. - if isinstance(new_instruction.operation, ForLoopOp): - old_op = new_instruction.operation - indexset, loop_param, body = old_op.params - if loop_param is not None: - new_loop_param = next(params) - new_op = ForLoopOp( - indexset, - new_loop_param, - body.assign_parameters({loop_param: new_loop_param}), - ) - new_instruction = new_instruction.replace(operation=new_op) - out._append(new_instruction) - return out - - return worker(circuit) diff --git a/qiskit/test/base.py b/qiskit/test/base.py deleted file mode 100644 index 04cd0f1fafe0..000000000000 --- a/qiskit/test/base.py +++ /dev/null @@ -1,343 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -# pylint: disable=invalid-name - -"""Base TestCases for the unit tests. - -Implementors of unit tests for Terra are encouraged to subclass -``QiskitTestCase`` in order to take advantage of utility functions (for example, -the environment variables for customizing different options), and the -decorators in the ``decorators`` package. -""" - -import inspect -import logging -import os -import sys -import warnings -import unittest -from unittest.util import safe_repr - -from qiskit.tools.parallel import get_platform_parallel_default -from qiskit.utils import optionals as _optionals -from qiskit.circuit import QuantumCircuit -from .decorators import enforce_subclasses_call -from .utils import Path, setup_test_logging - - -__unittest = True # Allows shorter stack trace for .assertDictAlmostEqual - - -# If testtools is installed use that as a (mostly) drop in replacement for -# unittest's TestCase. This will enable the fixtures used for capturing stdout -# stderr, and pylogging to attach the output to stestr's result stream. -if _optionals.HAS_TESTTOOLS: - import testtools - - class BaseTestCase(testtools.TestCase): - """Base test class.""" - - # testtools maintains their own version of assert functions which mostly - # behave as value adds to the std unittest assertion methods. However, - # for assertEquals and assertRaises modern unittest has diverged from - # the forks in testtools and offer more (or different) options that are - # incompatible testtools versions. Just use the stdlib versions so that - # our tests work as expected. - assertRaises = unittest.TestCase.assertRaises - assertEqual = unittest.TestCase.assertEqual - -else: - - class BaseTestCase(unittest.TestCase): - """Base test class.""" - - pass - - -@enforce_subclasses_call(["setUp", "setUpClass", "tearDown", "tearDownClass"]) -class BaseQiskitTestCase(BaseTestCase): - """Additions for test cases for all Qiskit-family packages. - - The additions here are intended for all packages, not just Terra. Terra-specific logic should - be in the Terra-specific classes.""" - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.__setup_called = False - self.__teardown_called = False - - def setUp(self): - super().setUp() - self.addTypeEqualityFunc(QuantumCircuit, self.assertQuantumCircuitEqual) - if self.__setup_called: - raise ValueError( - "In File: %s\n" - "TestCase.setUp was already called. Do not explicitly call " - "setUp from your tests. In your own setUp, use super to call " - "the base setUp." % (sys.modules[self.__class__.__module__].__file__,) - ) - self.__setup_called = True - - def tearDown(self): - super().tearDown() - if self.__teardown_called: - raise ValueError( - "In File: %s\n" - "TestCase.tearDown was already called. Do not explicitly call " - "tearDown from your tests. In your own tearDown, use super to " - "call the base tearDown." % (sys.modules[self.__class__.__module__].__file__,) - ) - self.__teardown_called = True - - @staticmethod - def _get_resource_path(filename, path=Path.TEST): - """Get the absolute path to a resource. - - Args: - filename (string): filename or relative path to the resource. - path (Path): path used as relative to the filename. - - Returns: - str: the absolute path to the resource. - """ - return os.path.normpath(os.path.join(path.value, filename)) - - def assertQuantumCircuitEqual(self, qc1, qc2, msg=None): - """Extra assertion method to give a better error message when two circuits are unequal.""" - if qc1 == qc2: - return - if msg is None: - msg = "The two circuits are not equal." - msg += f""" -Left circuit: -{qc1} - -Right circuit: -{qc2}""" - raise self.failureException(msg) - - def assertDictAlmostEqual( - self, dict1, dict2, delta=None, msg=None, places=None, default_value=0 - ): - """Assert two dictionaries with numeric values are almost equal. - - Fail if the two dictionaries are unequal as determined by - comparing that the difference between values with the same key are - not greater than delta (default 1e-8), or that difference rounded - to the given number of decimal places is not zero. If a key in one - dictionary is not in the other the default_value keyword argument - will be used for the missing value (default 0). If the two objects - compare equal then they will automatically compare almost equal. - - Args: - dict1 (dict): a dictionary. - dict2 (dict): a dictionary. - delta (number): threshold for comparison (defaults to 1e-8). - msg (str): return a custom message on failure. - places (int): number of decimal places for comparison. - default_value (number): default value for missing keys. - - Raises: - TypeError: if the arguments are not valid (both `delta` and - `places` are specified). - AssertionError: if the dictionaries are not almost equal. - """ - - error_msg = dicts_almost_equal(dict1, dict2, delta, places, default_value) - - if error_msg: - msg = self._formatMessage(msg, error_msg) - raise self.failureException(msg) - - def enable_parallel_processing(self): - """ - Enables parallel processing, for the duration of a test, on platforms - that support it. This is done by temporarily overriding the value of - the QISKIT_PARALLEL environment variable with the platform specific default. - """ - parallel_default = str(get_platform_parallel_default()).upper() - - def set_parallel_env(name, value): - os.environ[name] = value - - self.addCleanup( - lambda value: set_parallel_env("QISKIT_PARALLEL", value), - os.getenv("QISKIT_PARALLEL", parallel_default), - ) - - os.environ["QISKIT_PARALLEL"] = parallel_default - - -class QiskitTestCase(BaseQiskitTestCase): - """Terra-specific extra functionality for test cases.""" - - def tearDown(self): - super().tearDown() - # Reset the default providers, as in practice they acts as a singleton - # due to importing the instances from the top-level qiskit namespace. - from qiskit.providers.basicaer import BasicAer - - BasicAer._backends = BasicAer._verify_backends() - - @classmethod - def setUpClass(cls): - super().setUpClass() - # Determines if the TestCase is using IBMQ credentials. - cls.using_ibmq_credentials = False - # Set logging to file and stdout if the LOG_LEVEL envar is set. - cls.log = logging.getLogger(cls.__name__) - if os.getenv("LOG_LEVEL"): - filename = "%s.log" % os.path.splitext(inspect.getfile(cls))[0] - setup_test_logging(cls.log, os.getenv("LOG_LEVEL"), filename) - - warnings.filterwarnings("error", category=DeprecationWarning) - allow_DeprecationWarning_modules = [ - "test.python.pulse.test_parameters", - "test.python.pulse.test_transforms", - "test.python.circuit.test_gate_power", - "test.python.pulse.test_builder", - "test.python.pulse.test_block", - "test.python.quantum_info.operators.symplectic.test_legacy_pauli", - "qiskit.quantum_info.operators.pauli", - "pybobyqa", - "numba", - "qiskit.utils.measurement_error_mitigation", - "qiskit.circuit.library.standard_gates.x", - "qiskit.pulse.schedule", - "qiskit.pulse.instructions.instruction", - "qiskit.pulse.instructions.play", - "qiskit.pulse.library.parametric_pulses", - "qiskit.quantum_info.operators.symplectic.pauli", - "test.python.dagcircuit.test_dagcircuit", - "importlib_metadata", - ] - for mod in allow_DeprecationWarning_modules: - warnings.filterwarnings("default", category=DeprecationWarning, module=mod) - allow_DeprecationWarning_message = [ - r"elementwise comparison failed.*", - r"The jsonschema validation included in qiskit-terra.*", - r"The DerivativeBase.parameter_expression_grad method.*", - r"The property ``qiskit\.circuit\.bit\.Bit\.(register|index)`` is deprecated.*", - r"The CXDirection pass has been deprecated", - r"The pauli_basis function with PauliTable.*", - # Caused by internal scikit-learn scipy usage - r"The 'sym_pos' keyword is deprecated and should be replaced by using", - # jupyter_client 7.4.8 uses deprecated shims in pyzmq that raise warnings with pyzmq 25. - # These are due to be fixed by jupyter_client 8, see: - # - https://github.com/jupyter/jupyter_client/issues/913 - # - https://github.com/jupyter/jupyter_client/pull/842 - r"zmq\.eventloop\.ioloop is deprecated in pyzmq .*", - ] - for msg in allow_DeprecationWarning_message: - warnings.filterwarnings("default", category=DeprecationWarning, message=msg) - - allow_aer_DeprecationWarning_message = [ - # This warning should be fixed once Qiskit/qiskit-aer#1761 is in a release version of Aer. - "Setting metadata to None.*", - # and this one once Qiskit/qiskit-aer#1945 is merged and released. - r"The method ``qiskit\.circuit\.quantumcircuit\.QuantumCircuit\.i\(\)`` is " - r"deprecated as of qiskit-terra 0\.45\.0\. It will be removed no earlier than 3 " - r"months after the release date\. Use QuantumCircuit\.id as direct replacement\.", - ] - - for msg in allow_aer_DeprecationWarning_message: - warnings.filterwarnings( - "default", category=DeprecationWarning, module="qiskit_aer.*", message=msg - ) - - -class FullQiskitTestCase(QiskitTestCase): - """Terra-specific further additions for test cases, if ``testtools`` is available. - - It is not normally safe to derive from this class by name; on import, Terra checks if the - necessary packages are available, and binds this class to the name :obj:`~QiskitTestCase` if so. - If you derive directly from it, you may try and instantiate the class without satisfying its - dependencies.""" - - @_optionals.HAS_FIXTURES.require_in_call("output-capturing test cases") - def setUp(self): - import fixtures - - super().setUp() - if os.environ.get("QISKIT_TEST_CAPTURE_STREAMS"): - stdout = self.useFixture(fixtures.StringStream("stdout")).stream - self.useFixture(fixtures.MonkeyPatch("sys.stdout", stdout)) - stderr = self.useFixture(fixtures.StringStream("stderr")).stream - self.useFixture(fixtures.MonkeyPatch("sys.stderr", stderr)) - self.useFixture(fixtures.LoggerFixture(nuke_handlers=False, level=None)) - - -def dicts_almost_equal(dict1, dict2, delta=None, places=None, default_value=0): - """Test if two dictionaries with numeric values are almost equal. - - Fail if the two dictionaries are unequal as determined by - comparing that the difference between values with the same key are - not greater than delta (default 1e-8), or that difference rounded - to the given number of decimal places is not zero. If a key in one - dictionary is not in the other the default_value keyword argument - will be used for the missing value (default 0). If the two objects - compare equal then they will automatically compare almost equal. - - Args: - dict1 (dict): a dictionary. - dict2 (dict): a dictionary. - delta (number): threshold for comparison (defaults to 1e-8). - places (int): number of decimal places for comparison. - default_value (number): default value for missing keys. - - Raises: - TypeError: if the arguments are not valid (both `delta` and - `places` are specified). - - Returns: - String: Empty string if dictionaries are almost equal. A description - of their difference if they are deemed not almost equal. - """ - - def valid_comparison(value): - """compare value to delta, within places accuracy""" - if places is not None: - return round(value, places) == 0 - else: - return value < delta - - # Check arguments. - if dict1 == dict2: - return "" - if places is not None: - if delta is not None: - raise TypeError("specify delta or places not both") - msg_suffix = " within %s places" % places - else: - delta = delta or 1e-8 - msg_suffix = " within %s delta" % delta - - # Compare all keys in both dicts, populating error_msg. - error_msg = "" - for key in set(dict1.keys()) | set(dict2.keys()): - val1 = dict1.get(key, default_value) - val2 = dict2.get(key, default_value) - if not valid_comparison(abs(val1 - val2)): - error_msg += f"({safe_repr(key)}: {safe_repr(val1)} != {safe_repr(val2)}), " - - if error_msg: - return error_msg[:-2] + msg_suffix - else: - return "" - - -# Maintain naming backwards compatibility for downstream packages. -BasicQiskitTestCase = QiskitTestCase - -if _optionals.HAS_TESTTOOLS and _optionals.HAS_FIXTURES: - QiskitTestCase = FullQiskitTestCase diff --git a/qiskit/test/decorators.py b/qiskit/test/decorators.py deleted file mode 100644 index a15ab9ccc361..000000000000 --- a/qiskit/test/decorators.py +++ /dev/null @@ -1,308 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - - -"""Decorator for using with Qiskit unit tests.""" - -import collections.abc -import functools -import os -import socket -import sys -from typing import Union, Callable, Type, Iterable -import unittest - -from qiskit.utils import wrap_method -from .testing_options import get_test_options - -HAS_NET_CONNECTION = None - - -def _has_connection(hostname, port): - """Checks if internet connection exists to host via specified port. - - If any exception is raised while trying to open a socket this will return - false. - - Args: - hostname (str): Hostname to connect to. - port (int): Port to connect to - - Returns: - bool: Has connection or not - - """ - try: - host = socket.gethostbyname(hostname) - socket.create_connection((host, port), 2).close() - return True - except Exception: # pylint: disable=broad-except - return False - - -def is_aer_provider_available(): - """Check if the C++ simulator can be instantiated. - - Returns: - bool: True if simulator executable is available - """ - # TODO: HACK FROM THE DEPTHS OF DESPAIR AS AER DOES NOT WORK ON MAC - if sys.platform == "darwin": - return False - try: - import qiskit.providers.aer # pylint: disable=unused-import - except ImportError: - return False - return True - - -def requires_aer_provider(test_item): - """Decorator that skips test if qiskit aer provider is not available - - Args: - test_item (callable): function or class to be decorated. - - Returns: - callable: the decorated function. - """ - reason = "Aer provider not found, skipping test" - return unittest.skipIf(not is_aer_provider_available(), reason)(test_item) - - -def slow_test(func): - """Decorator that signals that the test takes minutes to run. - - Args: - func (callable): test function to be decorated. - - Returns: - callable: the decorated function. - """ - - @functools.wraps(func) - def _wrapper(*args, **kwargs): - skip_slow = not TEST_OPTIONS["run_slow"] - if skip_slow: - raise unittest.SkipTest("Skipping slow tests") - - return func(*args, **kwargs) - - return _wrapper - - -def _get_credentials(): - """Finds the credentials for a specific test and options. - - Returns: - Credentials: set of credentials - - Raises: - SkipTest: when credentials can't be found - """ - try: - from qiskit.providers.ibmq.credentials import Credentials, discover_credentials - except ImportError as ex: - raise unittest.SkipTest( - "qiskit-ibmq-provider could not be found, " - "and is required for executing online tests. " - 'To install, run "pip install qiskit-ibmq-provider" ' - "or check your installation." - ) from ex - - if os.getenv("IBMQ_TOKEN") and os.getenv("IBMQ_URL"): - return Credentials(os.getenv("IBMQ_TOKEN"), os.getenv("IBMQ_URL")) - elif os.getenv("QISKIT_TESTS_USE_CREDENTIALS_FILE"): - # Attempt to read the standard credentials. - discovered_credentials = discover_credentials() - - if discovered_credentials: - # Decide which credentials to use for testing. - if len(discovered_credentials) > 1: - raise unittest.SkipTest( - "More than 1 credential set found, use: " - "IBMQ_TOKEN and IBMQ_URL env variables to " - "set credentials explicitly" - ) - - # Use the first available credentials. - return list(discovered_credentials.values())[0] - raise unittest.SkipTest( - "No IBMQ credentials found for running the test. This is required for running online tests." - ) - - -def online_test(func): - """Decorator that signals that the test uses the network (and the online API): - - It involves: - * determines if the test should be skipped by checking environment - variables. - * if the `USE_ALTERNATE_ENV_CREDENTIALS` environment variable is - set, it reads the credentials from an alternative set of environment - variables. - * if the test is not skipped, it reads `qe_token` and `qe_url` from - `Qconfig.py`, environment variables or qiskitrc. - * if the test is not skipped, it appends `qe_token` and `qe_url` as - arguments to the test function. - - Args: - func (callable): test function to be decorated. - - Returns: - callable: the decorated function. - """ - - @functools.wraps(func) - def _wrapper(self, *args, **kwargs): - # To avoid checking the connection in each test - global HAS_NET_CONNECTION # pylint: disable=global-statement - - if TEST_OPTIONS["skip_online"]: - raise unittest.SkipTest("Skipping online tests") - - if HAS_NET_CONNECTION is None: - HAS_NET_CONNECTION = _has_connection("qiskit.org", 443) - - if not HAS_NET_CONNECTION: - raise unittest.SkipTest("Test requires internet connection.") - - credentials = _get_credentials() - self.using_ibmq_credentials = credentials.is_ibmq() - kwargs.update({"qe_token": credentials.token, "qe_url": credentials.url}) - - return func(self, *args, **kwargs) - - return _wrapper - - -def enforce_subclasses_call( - methods: Union[str, Iterable[str]], attr: str = "_enforce_subclasses_call_cache" -) -> Callable[[Type], Type]: - """Class decorator which enforces that if any subclasses define on of the ``methods``, they must - call ``super().()`` or face a ``ValueError`` at runtime. - - This is unlikely to be useful for concrete test classes, who are not normally subclassed. It - should not be used on user-facing code, because it prevents subclasses from being free to - override parent-class behavior, even when the parent-class behavior is not needed. - - This adds behavior to the ``__init__`` and ``__init_subclass__`` methods of the class, in - addition to the named methods of this class and all subclasses. The checks could be averted in - grandchildren if a child class overrides ``__init_subclass__`` without up-calling the decorated - class's method, though this would typically break inheritance principles. - - Arguments: - methods: - Names of the methods to add the enforcement to. These do not necessarily need to be - defined in the class body, provided they are somewhere in the method-resolution tree. - - attr: - The attribute which will be added to all instances of this class and subclasses, in - order to manage the call enforcement. This can be changed to avoid clashes. - - Returns: - A decorator, which returns its input class with the class with the relevant methods modified - to include checks, and injection code in the ``__init_subclass__`` method. - """ - - methods = {methods} if isinstance(methods, str) else set(methods) - - def initialize_call_memory(self, *_args, **_kwargs): - """Add the extra attribute used for tracking the method calls.""" - setattr(self, attr, set()) - - def save_call_status(name): - """Decorator, whose return saves the fact that the top-level method call occurred.""" - - def out(self, *_args, **_kwargs): - getattr(self, attr).add(name) - - return out - - def clear_call_status(name): - """Decorator, whose return clears the call status of the method ``name``. This prepares the - call tracking for the child class's method call.""" - - def out(self, *_args, **_kwargs): - getattr(self, attr).discard(name) - - return out - - def enforce_call_occurred(name): - """Decorator, whose return checks that the top-level method call occurred, and raises - ``ValueError`` if not. Concretely, this is an assertion that ``save_call_status`` ran.""" - - def out(self, *_args, **_kwargs): - cache = getattr(self, attr) - if name not in cache: - classname = self.__name__ if isinstance(self, type) else type(self).__name__ - raise ValueError( - f"Parent '{name}' method was not called by '{classname}.{name}'." - f" Ensure you have put in calls to 'super().{name}()'." - ) - - return out - - def wrap_subclass_methods(cls): - """Wrap all the ``methods`` of ``cls`` with the call-tracking assertions that the top-level - versions of the methods were called (likely via ``super()``).""" - # Only wrap methods who are directly defined in this class; if we're resolving to a method - # higher up the food chain, then it will already have been wrapped. - for name in set(cls.__dict__) & methods: - wrap_method( - cls, - name, - before=clear_call_status(name), - after=enforce_call_occurred(name), - ) - - def decorator(cls): - # Add a class-level memory on, so class methods will work as well. Instances will override - # this on instantiation, to keep the "namespace" of class- and instance-methods separate. - initialize_call_memory(cls) - # Do the extra bits after the main body of __init__ so we can check we're not overwriting - # anything, and after __init_subclass__ in case the decorated class wants to influence the - # creation of the subclass's methods before we get to them. - wrap_method(cls, "__init__", after=initialize_call_memory) - for name in methods: - wrap_method(cls, name, before=save_call_status(name)) - wrap_method(cls, "__init_subclass__", after=wrap_subclass_methods) - return cls - - return decorator - - -class _TestOptions(collections.abc.Mapping): - """Lazy-loading view onto the test options retrieved from the environment.""" - - __slots__ = ("_options",) - - def __init__(self): - self._options = None - - def _load(self): - if self._options is None: - self._options = get_test_options() - - def __getitem__(self, key): - self._load() - return self._options[key] - - def __iter__(self): - self._load() - return iter(self._options) - - def __len__(self): - self._load() - return len(self._options) - - -TEST_OPTIONS = _TestOptions() diff --git a/qiskit/test/ibmq_mock.py b/qiskit/test/ibmq_mock.py deleted file mode 100644 index 73b30f4f44ec..000000000000 --- a/qiskit/test/ibmq_mock.py +++ /dev/null @@ -1,45 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2019. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Mock functions for qiskit.IBMQ.""" - -from unittest.mock import MagicMock -import qiskit -from qiskit.providers import fake_provider as backend_mocks - - -def mock_get_backend(backend): - """Replace qiskit.IBMQ with a mock that returns a single backend. - - Note this will set the value of qiskit.IBMQ to a MagicMock object. It is - intended to be run as part of docstrings with jupyter-example in a hidden - cell so that later examples which rely on ibmq devices so that the docs can - be built without requiring configured credentials. If used outside of this - context be aware that you will have to manually restore qiskit.IBMQ the - value to qiskit.providers.ibmq.IBMQ after you finish using your mock. - - Args: - backend (str): The class name as a string for the fake device to - return from the mock IBMQ object. For example, FakeVigo. - Raises: - NameError: If the specified value of backend - """ - mock_ibmq = MagicMock() - mock_provider = MagicMock() - if not hasattr(backend_mocks, backend): - raise NameError( - "The specified backend name is not a valid mock from qiskit.providers.fake_provider." - ) - fake_backend = getattr(backend_mocks, backend)() - mock_provider.get_backend.return_value = fake_backend - mock_ibmq.get_provider.return_value = mock_provider - qiskit.IBMQ = mock_ibmq diff --git a/qiskit/test/mock/__init__.py b/qiskit/test/mock/__init__.py deleted file mode 100644 index 760a0b1772a9..000000000000 --- a/qiskit/test/mock/__init__.py +++ /dev/null @@ -1,40 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2019. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -""" -Utilities for mocking the IBMQ provider, including job responses and backends. - -The module includes dummy provider, backends, and jobs. -The purpose of these classes is to fake backends for testing purposes: -testing local timeouts, arbitrary responses or behavior, etc. - -The mock devices are mainly for testing the compiler. -""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import the desired object directly 'qiskit.providers.fake_provider'.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/__init__.py b/qiskit/test/mock/backends/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/almaden/__init__.py b/qiskit/test/mock/backends/almaden/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/almaden/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/armonk/__init__.py b/qiskit/test/mock/backends/armonk/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/armonk/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/athens/__init__.py b/qiskit/test/mock/backends/athens/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/athens/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/belem/__init__.py b/qiskit/test/mock/backends/belem/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/belem/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/boeblingen/__init__.py b/qiskit/test/mock/backends/boeblingen/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/boeblingen/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/bogota/__init__.py b/qiskit/test/mock/backends/bogota/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/bogota/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/brooklyn/__init__.py b/qiskit/test/mock/backends/brooklyn/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/brooklyn/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/burlington/__init__.py b/qiskit/test/mock/backends/burlington/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/burlington/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/cairo/__init__.py b/qiskit/test/mock/backends/cairo/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/cairo/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/cambridge/__init__.py b/qiskit/test/mock/backends/cambridge/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/cambridge/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/casablanca/__init__.py b/qiskit/test/mock/backends/casablanca/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/casablanca/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/essex/__init__.py b/qiskit/test/mock/backends/essex/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/essex/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/guadalupe/__init__.py b/qiskit/test/mock/backends/guadalupe/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/guadalupe/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/hanoi/__init__.py b/qiskit/test/mock/backends/hanoi/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/hanoi/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/jakarta/__init__.py b/qiskit/test/mock/backends/jakarta/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/jakarta/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/johannesburg/__init__.py b/qiskit/test/mock/backends/johannesburg/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/johannesburg/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/kolkata/__init__.py b/qiskit/test/mock/backends/kolkata/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/kolkata/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/lagos/__init__.py b/qiskit/test/mock/backends/lagos/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/lagos/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/lima/__init__.py b/qiskit/test/mock/backends/lima/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/lima/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/london/__init__.py b/qiskit/test/mock/backends/london/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/london/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/manhattan/__init__.py b/qiskit/test/mock/backends/manhattan/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/manhattan/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/manila/__init__.py b/qiskit/test/mock/backends/manila/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/manila/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/melbourne/__init__.py b/qiskit/test/mock/backends/melbourne/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/melbourne/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/montreal/__init__.py b/qiskit/test/mock/backends/montreal/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/montreal/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/mumbai/__init__.py b/qiskit/test/mock/backends/mumbai/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/mumbai/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/nairobi/__init__.py b/qiskit/test/mock/backends/nairobi/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/nairobi/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/ourense/__init__.py b/qiskit/test/mock/backends/ourense/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/ourense/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/paris/__init__.py b/qiskit/test/mock/backends/paris/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/paris/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/poughkeepsie/__init__.py b/qiskit/test/mock/backends/poughkeepsie/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/poughkeepsie/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/quito/__init__.py b/qiskit/test/mock/backends/quito/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/quito/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/rochester/__init__.py b/qiskit/test/mock/backends/rochester/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/rochester/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/rome/__init__.py b/qiskit/test/mock/backends/rome/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/rome/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/rueschlikon/__init__.py b/qiskit/test/mock/backends/rueschlikon/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/rueschlikon/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/santiago/__init__.py b/qiskit/test/mock/backends/santiago/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/santiago/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/singapore/__init__.py b/qiskit/test/mock/backends/singapore/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/singapore/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/sydney/__init__.py b/qiskit/test/mock/backends/sydney/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/sydney/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/tenerife/__init__.py b/qiskit/test/mock/backends/tenerife/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/tenerife/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/tokyo/__init__.py b/qiskit/test/mock/backends/tokyo/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/tokyo/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/toronto/__init__.py b/qiskit/test/mock/backends/toronto/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/toronto/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/valencia/__init__.py b/qiskit/test/mock/backends/valencia/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/valencia/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/vigo/__init__.py b/qiskit/test/mock/backends/vigo/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/vigo/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/washington/__init__.py b/qiskit/test/mock/backends/washington/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/washington/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/mock/backends/yorktown/__init__.py b/qiskit/test/mock/backends/yorktown/__init__.py deleted file mode 100644 index 7682c117d41c..000000000000 --- a/qiskit/test/mock/backends/yorktown/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Deprecation warnings for moved functionality.""" - -import warnings - -import qiskit.providers.fake_provider - - -def __getattr__(name): - if name.startswith("_"): - # Some Python components (including tests) do funny things with dunders. - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - warnings.warn( - f"The module '{__name__}' is deprecated since " - "Qiskit Terra 0.21.0, and will be removed 3 months or more later. " - "Instead, you should import from `qiskit.providers.fake_provider` directly.", - category=DeprecationWarning, - stacklevel=2, - ) - return getattr(qiskit.providers.fake_provider, name) diff --git a/qiskit/test/providers/__init__.py b/qiskit/test/providers/__init__.py deleted file mode 100644 index 73c3a1dae785..000000000000 --- a/qiskit/test/providers/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2019. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Base TestCases for provider and backends.""" - -from .backend import BackendTestCase -from .provider import ProviderTestCase diff --git a/qiskit/test/providers/backend.py b/qiskit/test/providers/backend.py deleted file mode 100644 index 83832b8a29e7..000000000000 --- a/qiskit/test/providers/backend.py +++ /dev/null @@ -1,75 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2019. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Base TestCase for testing backends.""" - -from unittest import SkipTest - -from qiskit import execute -from ..base import QiskitTestCase -from ..reference_circuits import ReferenceCircuits - - -class BackendTestCase(QiskitTestCase): - """Test case for backends. - - Implementers of backends are encouraged to subclass and customize this - TestCase, as it contains a "canonical" series of tests in order to ensure - the backend functionality matches the specifications. - - Members: - backend_cls (BaseBackend): backend to be used in this test case. Its - instantiation can be further customized by overriding the - ``_get_backend`` function. - circuit (QuantumCircuit): circuit to be used for the tests. - """ - - backend_cls = None - circuit = ReferenceCircuits.bell() - - def setUp(self): - super().setUp() - self.backend = self._get_backend() - - @classmethod - def setUpClass(cls): - if cls is BackendTestCase: - raise SkipTest("Skipping base class tests") - super().setUpClass() - - def _get_backend(self): - """Return an instance of a Provider.""" - return self.backend_cls() # pylint: disable=not-callable - - def test_configuration(self): - """Test backend.configuration().""" - configuration = self.backend.configuration() - return configuration - - def test_properties(self): - """Test backend.properties().""" - properties = self.backend.properties() - if self.backend.configuration().simulator: - self.assertEqual(properties, None) - return properties - - def test_status(self): - """Test backend.status().""" - status = self.backend.status() - return status - - def test_run_circuit(self): - """Test running a single circuit.""" - job = execute(self.circuit, self.backend) - result = job.result() - self.assertEqual(result.success, True) - return result diff --git a/qiskit/test/providers/provider.py b/qiskit/test/providers/provider.py deleted file mode 100644 index 8170ae35859b..000000000000 --- a/qiskit/test/providers/provider.py +++ /dev/null @@ -1,59 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2019. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Base TestCase for testing Providers.""" - -from unittest import SkipTest - -from ..base import QiskitTestCase - - -class ProviderTestCase(QiskitTestCase): - """Test case for Providers. - - Implementers of providers are encouraged to subclass and customize this - TestCase, as it contains a "canonical" series of tests in order to ensure - the provider functionality matches the specifications. - - Members: - provider_cls (BaseProvider): provider to be used in this test case. Its - instantiation can be further customized by overriding the - ``_get_provider`` function. - backend_name (str): name of a backend provided by the provider. - """ - - provider_cls = None - backend_name = "" - - def setUp(self): - super().setUp() - self.provider = self._get_provider() - - @classmethod - def setUpClass(cls): - if cls is ProviderTestCase: - raise SkipTest("Skipping base class tests") - super().setUpClass() - - def _get_provider(self): - """Return an instance of a Provider.""" - return self.provider_cls() # pylint: disable=not-callable - - def test_backends(self): - """Test the provider has backends.""" - backends = self.provider.backends() - self.assertTrue(len(backends) > 0) - - def test_get_backend(self): - """Test getting a backend from the provider.""" - backend = self.provider.get_backend(name=self.backend_name) - self.assertEqual(backend.name(), self.backend_name) diff --git a/qiskit/test/reference_circuits.py b/qiskit/test/reference_circuits.py deleted file mode 100644 index 8b94dfa89a28..000000000000 --- a/qiskit/test/reference_circuits.py +++ /dev/null @@ -1,41 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2019. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Reference circuits used by the tests.""" - -from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister - - -class ReferenceCircuits: - """Container for reference circuits used by the tests.""" - - @staticmethod - def bell(): - """Return a Bell circuit.""" - qr = QuantumRegister(2, name="qr") - cr = ClassicalRegister(2, name="qc") - qc = QuantumCircuit(qr, cr, name="bell") - qc.h(qr[0]) - qc.cx(qr[0], qr[1]) - qc.measure(qr, cr) - - return qc - - @staticmethod - def bell_no_measure(): - """Return a Bell circuit.""" - qr = QuantumRegister(2, name="qr") - qc = QuantumCircuit(qr, name="bell_no_measure") - qc.h(qr[0]) - qc.cx(qr[0], qr[1]) - - return qc diff --git a/qiskit/test/testing_options.py b/qiskit/test/testing_options.py deleted file mode 100644 index 0ecd8beea15d..000000000000 --- a/qiskit/test/testing_options.py +++ /dev/null @@ -1,93 +0,0 @@ -# This code is part of Qiskit. -# -# (C) Copyright IBM 2017, 2018. -# -# This code is licensed under the Apache License, Version 2.0. You may -# obtain a copy of this license in the LICENSE.txt file in the root directory -# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. -# -# Any modifications or derivative works of this code must retain this -# copyright notice, and modified files need to carry a notice indicating -# that they have been altered from the originals. - -"""Obtain and set the options in QISKIT_TESTS, used for running the tests.""" - -import os -import logging - -logger = logging.getLogger(__name__) - - -def get_test_options(option_var="QISKIT_TESTS"): - """Read option_var from env and returns a dict in which the test options are set. - - Args: - option_var (str): The env var to read. Default: 'QISKIT_TESTS' - - Returns: - dict: A dictionary with the format {