From 1802f19140138ffc0ac9c31dc4637882c01a0e46 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 10 Feb 2018 13:33:34 +0000 Subject: [PATCH 1/3] Don't print, use the terminal reporter --- pytest_test_groups/__init__.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pytest_test_groups/__init__.py b/pytest_test_groups/__init__.py index f0ff566..548b240 100644 --- a/pytest_test_groups/__init__.py +++ b/pytest_test_groups/__init__.py @@ -1,7 +1,12 @@ -import math +# -*- coding: utf-8 -*- +# Import python libs +import math from random import Random +# Import 3rd-party libs +from _pytest.config import create_terminal_writer + def get_group_size(total_items, total_groups): return int(math.ceil(float(total_items) / total_groups)) @@ -46,4 +51,14 @@ def pytest_collection_modifyitems(session, config, items): del items[:] items.extend(tests_in_group) - print('Running test group #{0} ({1} tests)'.format(group_id, len(items))) + + terminal_reporter = config.pluginmanager.get_plugin('terminalreporter') + terminal_writer = create_terminal_writer(config) + message = terminal_writer.markup( + 'Running test group #{0} ({1} tests)\n'.format( + group_id, + len(items) + ), + yellow=True + ) + terminal_reporter.write(message) From 0e0374c89aaf0650ce359a589970389fe309f50d Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 10 Feb 2018 13:37:48 +0000 Subject: [PATCH 2/3] A single step is enough to re-populate the list --- pytest_test_groups/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pytest_test_groups/__init__.py b/pytest_test_groups/__init__.py index 548b240..258d130 100644 --- a/pytest_test_groups/__init__.py +++ b/pytest_test_groups/__init__.py @@ -9,10 +9,12 @@ def get_group_size(total_items, total_groups): + """Return the group size.""" return int(math.ceil(float(total_items) / total_groups)) def get_group(items, group_size, group_id): + """Get the items from the passed in group based on group size.""" start = group_size * (group_id - 1) end = start + group_size @@ -48,9 +50,7 @@ def pytest_collection_modifyitems(session, config, items): group_size = get_group_size(total_items, group_count) tests_in_group = get_group(items, group_size, group_id) - del items[:] - items.extend(tests_in_group) - + items[:] = tests_in_group terminal_reporter = config.pluginmanager.get_plugin('terminalreporter') terminal_writer = create_terminal_writer(config) From b93e27c194e1caad9a9126fc7b30059e5fec12e4 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 10 Feb 2018 13:52:37 +0000 Subject: [PATCH 3/3] Wheel packages can be universal --- setup.cfg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.cfg b/setup.cfg index 791f075..f3d42d1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,5 @@ [flake8] max-line-length = 119 + +[wheel] +universal = true