From 4e717eb6261f61f6f4bef255522b835a85354594 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 21 Mar 2018 20:20:46 -0300 Subject: [PATCH 1/2] Remove `terminal.flatten` function in favor of collapse from more_itertools --- _pytest/terminal.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/_pytest/terminal.py b/_pytest/terminal.py index 7dc36e7d7..f8ad33c10 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -12,6 +12,7 @@ import time import pluggy import py import six +from more_itertools import collapse import pytest from _pytest import nodes @@ -442,7 +443,7 @@ class TerminalReporter(object): def _write_report_lines_from_hooks(self, lines): lines.reverse() - for line in flatten(lines): + for line in collapse(lines): self.write_line(line) def pytest_report_header(self, config): @@ -700,15 +701,6 @@ def repr_pythonversion(v=None): return str(v) -def flatten(values): - for x in values: - if isinstance(x, (list, tuple)): - for y in flatten(x): - yield y - else: - yield x - - def build_summary_stats_line(stats): keys = ("failed passed skipped deselected " "xfailed xpassed warnings error").split() From 6c2739d1e68c9a8da26a9dcae7645e4c793107bf Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 21 Mar 2018 20:23:17 -0300 Subject: [PATCH 2/2] Add CHANGELOG for #3330 --- changelog/3330.trivial.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/3330.trivial.rst diff --git a/changelog/3330.trivial.rst b/changelog/3330.trivial.rst new file mode 100644 index 000000000..ce5ec5882 --- /dev/null +++ b/changelog/3330.trivial.rst @@ -0,0 +1 @@ +Remove internal ``_pytest.terminal.flatten`` function in favor of ``more_itertools.collapse``.