Skip to content

Commit

Permalink
Removes stestr's grouping configuration. (#6399)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jorconnor authored May 12, 2021
1 parent 9b78934 commit 5664ab4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
1 change: 0 additions & 1 deletion .stestr.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[DEFAULT]
test_path=./test/python
group_regex=([^\.]*\.)*
7 changes: 4 additions & 3 deletions test/python/test_user_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
# pylint: disable=missing-docstring

import os
from uuid import uuid4

from qiskit import exceptions
from qiskit.test import QiskitTestCase
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)
Expand Down
21 changes: 12 additions & 9 deletions test/python/visualization/test_gate_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -45,11 +46,12 @@ def test_plot_gate_map(self, backend):
"""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.")
Expand All @@ -62,11 +64,12 @@ def test_plot_circuit_layout(self, backend):
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.")
Expand Down

0 comments on commit 5664ab4

Please sign in to comment.