diff --git a/pytest_test_groups/__init__.py b/pytest_test_groups/__init__.py index f0ff566..258d130 100644 --- a/pytest_test_groups/__init__.py +++ b/pytest_test_groups/__init__.py @@ -1,13 +1,20 @@ -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 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 @@ -43,7 +50,15 @@ 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) - - print('Running test group #{0} ({1} tests)'.format(group_id, len(items))) + items[:] = tests_in_group + + 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) 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