Skip to content

Commit 553338d

Browse files
committed
Parametrize tests, as @CAM-Gerlach suggested
1 parent b00b299 commit 553338d

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

qtpy/tests/test_qtcore.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,27 @@ def test_qtmsghandler():
2626
assert QtCore.qInstallMessageHandler is not None
2727

2828

29-
def test_QDateTime_toPython_and_toPyDateTime():
29+
@pytest.mark.parametrize('method', ['toPython', 'toPyDateTime'])
30+
def test_QDateTime_toPython_and_toPyDateTime(method):
3031
"""Test `QDateTime.toPython` and `QDateTime.toPyDateTime`"""
3132
q_datetime = QtCore.QDateTime(NOW)
32-
py_date = q_datetime.toPython()
33-
assert py_date == NOW
34-
py_date = q_datetime.toPyDateTime()
35-
assert py_date == NOW
33+
py_datetime = getattr(q_datetime, method)()
34+
assert py_datetime == NOW
3635

3736

38-
def test_QDate_toPython_and_toPyDate():
37+
@pytest.mark.parametrize('method', ['toPython', 'toPyDate'])
38+
def test_QDate_toPython_and_toPyDate(method):
3939
"""Test `QDate.toPython` and `QDate.toPyDate`"""
4040
q_date = QtCore.QDateTime(NOW).date()
41-
py_date = q_date.toPython()
42-
assert py_date == NOW.date()
43-
py_date = q_date.toPyDate()
41+
py_date = getattr(q_date, method)()
4442
assert py_date == NOW.date()
4543

4644

47-
def test_QTime_toPython_and_toPyTime():
45+
@pytest.mark.parametrize('method', ['toPython', 'toPyTime'])
46+
def test_QTime_toPython_and_toPyTime(method):
4847
"""Test `QTime.toPython` and `QTime.toPyTime`"""
4948
q_time = QtCore.QDateTime(NOW).time()
50-
py_time = q_time.toPython()
51-
assert py_time == NOW.time()
52-
py_time = q_time.toPyTime()
49+
py_time = getattr(q_time, method)()
5350
assert py_time == NOW.time()
5451

5552

0 commit comments

Comments
 (0)