Skip to content

Commit

Permalink
Merge pull request mark-adams#11 from s0undt3ch/features/hoowrap-term…
Browse files Browse the repository at this point in the history
…inalrep

Don't print, use the terminal reporter
  • Loading branch information
mark-adams authored Aug 1, 2018
2 parents 13f1f7a + b93e27c commit 3cacc84
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
25 changes: 20 additions & 5 deletions pytest_test_groups/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[flake8]
max-line-length = 119

[wheel]
universal = true

0 comments on commit 3cacc84

Please sign in to comment.