Removes stestr's grouping configuration. (#6399)

Removing  the grouping regex in .stestr.conf should allow stestr to pack its test workers better, and therefore improve the speed of test execution. However, pre-existing test cases utilizing non-unique tempfiles began to fail after the configuration change. This commit modifies such tests to pass under these new conditions. This also allows the test suite to properly execute using pytest-xdist.

Fixed #6105
This commit is contained in:
jorconnor 2021-05-12 15:06:06 -04:00 committed by GitHub
parent 9b7893439c
commit 5664ab4439
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 13 deletions

View File

@ -1,3 +1,2 @@
[DEFAULT]
test_path=./test/python
group_regex=([^\.]*\.)*

View File

@ -13,6 +13,7 @@
# pylint: disable=missing-docstring
import os
from uuid import uuid4
from qiskit import exceptions
from qiskit.test import QiskitTestCase
@ -20,9 +21,9 @@ from qiskit import user_config
class TestUserConfig(QiskitTestCase):
@classmethod
def setUpClass(cls):
cls.file_path = "temp.txt"
def setUp(self):
super().setUp()
self.file_path = "test_%s.conf" % uuid4()
def test_empty_file_read(self):
config = user_config.UserConfig(self.file_path)

View File

@ -12,8 +12,9 @@
"""A test for visualizing device coupling maps"""
import unittest
import os
from io import BytesIO
from PIL import Image
from ddt import ddt, data
from qiskit.test.mock import FakeProvider
from qiskit.test import QiskitTestCase
@ -45,11 +46,12 @@ class TestGateMap(QiskitVisualizationTestCase):
"""tests plotting of gate map of a device (20 qubit, 16 qubit, 14 qubit and 5 qubit)"""
n = backend.configuration().n_qubits
img_ref = path_to_diagram_reference(str(n) + "bit_quantum_computer.png")
filename = "temp.png"
fig = plot_gate_map(backend)
fig.savefig(filename)
self.assertImagesAreEqual(filename, img_ref, 0.2)
os.remove(filename)
with BytesIO() as img_buffer:
fig.savefig(img_buffer, format="png")
img_buffer.seek(0)
self.assertImagesAreEqual(Image.open(img_buffer), img_ref, 0.2)
plt.close(fig)
@data(*backends)
@unittest.skipIf(not HAS_MATPLOTLIB, "matplotlib not available.")
@ -62,11 +64,12 @@ class TestGateMap(QiskitVisualizationTestCase):
circuit._layout.add_register(qr)
n = backend.configuration().n_qubits
img_ref = path_to_diagram_reference(str(n) + "_plot_circuit_layout.png")
filename = str(n) + "_plot_circuit_layout_result.png"
fig = plot_circuit_layout(circuit, backend)
fig.savefig(filename)
self.assertImagesAreEqual(filename, img_ref, 0.1)
os.remove(filename)
with BytesIO() as img_buffer:
fig.savefig(img_buffer, format="png")
img_buffer.seek(0)
self.assertImagesAreEqual(Image.open(img_buffer), img_ref, 0.1)
plt.close(fig)
@unittest.skipIf(not HAS_MATPLOTLIB, "matplotlib not available.")