From 6be2136f20c076b98b63233a701493c79acd7c6c Mon Sep 17 00:00:00 2001 From: Zac-HD Date: Wed, 26 Sep 2018 22:02:14 +1000 Subject: [PATCH] Ensure user_properties is a list --- AUTHORS | 5 +++-- changelog/4034.bugfix.rst | 3 +++ src/_pytest/reports.py | 7 ++++++- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 changelog/4034.bugfix.rst diff --git a/AUTHORS b/AUTHORS index a65623820..2be74441a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -10,6 +10,7 @@ Ahn Ki-Wook Alan Velasco Alexander Johnson Alexei Kozlenok +Allan Feldman Anatoly Bubenkoff Anders Hovmöller Andras Tim @@ -179,6 +180,7 @@ Raphael Pierzina Raquel Alegre Ravi Chandra Roberto Polli +Roland Puntaier Romain Dorgueil Roman Bolshakov Ronny Pfannschmidt @@ -223,6 +225,5 @@ Wim Glenn Wouter van Ackooy Xuan Luong Xuecong Liao +Zac Hatfield-Dodds Zoltán Máté -Roland Puntaier -Allan Feldman diff --git a/changelog/4034.bugfix.rst b/changelog/4034.bugfix.rst new file mode 100644 index 000000000..44044fb29 --- /dev/null +++ b/changelog/4034.bugfix.rst @@ -0,0 +1,3 @@ +The ``.user_properties`` attribute of ``TestReport`` objects is a list +of (name, value) tuples, but could sometimes be instantiated as a tuple +of tuples. It is now always a list. diff --git a/src/_pytest/reports.py b/src/_pytest/reports.py index 33b906702..4d4ab2f17 100644 --- a/src/_pytest/reports.py +++ b/src/_pytest/reports.py @@ -110,7 +110,7 @@ class TestReport(BaseReport): when, sections=(), duration=0, - user_properties=(), + user_properties=None, **extra ): #: normalized collection node id @@ -136,6 +136,11 @@ class TestReport(BaseReport): #: user properties is a list of tuples (name, value) that holds user #: defined properties of the test + if user_properties is None: + user_properties = [] + elif not isinstance(user_properties, list): + # This used to be a tuple; so cast for backwards-compatibility + user_properties = list(user_properties) self.user_properties = user_properties #: list of pairs ``(str, str)`` of extra information which needs to