Skip to content

Commit bf619cd

Browse files
Merge branch 'dev_pytest8'
2 parents b9d99f4 + bfc2511 commit bf619cd

18 files changed

+84
-30
lines changed

pytest_parallel/plugin.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# This Source Code Form is subject to the terms of the Mozilla Public
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
import os
45
import sys
56
import subprocess
67
import tempfile
7-
import pytest
88
from pathlib import Path
99
import argparse
1010
import resource
11+
import pytest
12+
from _pytest.terminal import TerminalReporter
1113

1214
# --------------------------------------------------------------------------
1315
def pytest_addoption(parser):
@@ -164,9 +166,16 @@ def pytest_configure(config):
164166

165167
# only report to terminal if master process
166168
if not enable_terminal_reporter:
169+
# unregister the stdout terminal reporter
167170
terminal_reporter = config.pluginmanager.getplugin('terminalreporter')
168171
config.pluginmanager.unregister(terminal_reporter)
169172

173+
# Pytest relies on having a terminal reporter to decide on how to create error messages, see #12
174+
# Hence, register a terminal reporter that outputs to /dev/null
175+
null_file = open(os.devnull,'w')
176+
terminal_reporter = TerminalReporter(config, null_file)
177+
config.pluginmanager.register(terminal_reporter, "terminalreporter")
178+
170179

171180
# --------------------------------------------------------------------------
172181
@pytest.fixture

pytest_parallel/test/test_utils.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,10 @@
55

66

77
def test_group_items_by_parallel_steps():
8-
class callspec_mock:
9-
def __init__(self, n_proc):
10-
self.n_proc = n_proc
11-
12-
def getparam(self, s):
13-
assert s == "comm"
14-
return self.n_proc
15-
168
class item_mock:
17-
def __init__(self, name, n_procs):
9+
def __init__(self, name, n_proc):
1810
self.name = name
19-
self.callspec = callspec_mock(n_procs)
11+
self.n_proc = n_proc
2012

2113
n_workers = 4
2214
items = [

source.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[=]+ test session starts [=]+
2+
platform [^\n]*
3+
cachedir: [^\n]*
4+
?(?:metadata: [^\n]*)?
5+
rootdir: [^\n]*
6+
?(?:configfile: [^\n]*)?
7+
?(?:plugins: [^\n]*)?
8+
collecting ... [\s]*collected 1 item[\s]*
9+
?(?:Submitting tests to SLURM...)?
10+
?(?:SLURM job [^\n]* has been submitted)?
11+
12+
[^\n]*test_fail_complex_assert_two_procs.py::test_fail_with_complex_assert_reporting\[2\] FAILED
13+
14+
[=]+ FAILURES [=]+
15+
[_]+ test_fail_with_complex_assert_reporting\[2\] [_]+
16+
17+
[-]+ On rank 0 of 2 [-]+
18+
comm = <mpi4py.MPI.Intracomm object at [^\n]*>
19+
20+
@pytest_parallel.mark.parallel\(2\)
21+
def test_fail_with_complex_assert_reporting\(comm\):
22+
if comm.Get_rank\(\) == 0:
23+
> assert 1 == 0
24+
E assert 1 == 0
25+
26+
[^\n]*test_fail_complex_assert_two_procs.py:7: AssertionError
27+
28+
[-]+ On rank 1 of 2 [-]+
29+
comm = <mpi4py.MPI.Intracomm object at [^\n]*>
30+
31+
@pytest_parallel.mark.parallel\(2\)
32+
def test_fail_with_complex_assert_reporting\(comm\):
33+
if comm.Get_rank\(\) == 0:
34+
assert 1 == 0
35+
if comm.Get_rank\(\) == 1:
36+
> assert \(np.array\(\[0,1,2\]\) == np.array\(\[0,1,3\]\)\).all\(\)
37+
E assert False
38+
E \+ where False = <built-in method all of numpy\.ndarray object at [^\n]*>\(\)
39+
E \+ where <built-in method all of numpy\.ndarray object at [^\n]*> = array\(\[0, 1, 2\]\) == array\(\[0, 1, 3\]\)
40+
?(?:[^\n]*)?
41+
E Full diff:
42+
E - array\(\[0, 1, 3\]\)
43+
E \? \^
44+
E \+ array\(\[0, 1, 2\]\)
45+
E \? \^.all
46+
47+
[^\n]*test_fail_complex_assert_two_procs.py:9: AssertionError
48+
[=]+ short test summary info [=]+
49+
FAILED [^\n]*test_fail_complex_assert_two_procs.py::test_fail_with_complex_assert_reporting\[2\][^\n]*
50+
[=]+ 1 failed in [^\n]*s [=]+

test/pytest_parallel_refs/terminal_fixture_error

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ platform [^\n]*
33
cachedir: [^\n]*
44
?(?:metadata: [^\n]*)?
55
rootdir: [^\n]*
6+
?(?:configfile: [^\n]*)?
67
?(?:plugins: [^\n]*)?
78
collecting ... [\s]*collected 1 item[\s]*
89
?(?:Submitting tests to SLURM...)?

test/pytest_parallel_refs/terminal_parametrize

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ platform [^\n]*
33
cachedir: [^\n]*
44
?(?:metadata: [^\n]*)?
55
rootdir: [^\n]*
6+
?(?:configfile: [^\n]*)?
67
?(?:plugins: [^\n]*)?
78
collecting ... [\s]*collected 8 items[\s]*
89
?(?:Submitting tests to SLURM...)?

test/pytest_parallel_refs/terminal_scheduling

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ platform [^\n]*
33
cachedir: [^\n]*
44
?(?:metadata: [^\n]*)?
55
rootdir: [^\n]*
6+
?(?:configfile: [^\n]*)?
67
?(?:plugins: [^\n]*)?
78
collecting ... [\s]*collected 8 items[\s]*
89
?(?:Submitting tests to SLURM...)?

test/pytest_parallel_refs/terminal_seq

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ platform [^\n]*
33
cachedir: [^\n]*
44
?(?:metadata: [^\n]*)?
55
rootdir: [^\n]*
6+
?(?:configfile: [^\n]*)?
67
?(?:plugins: [^\n]*)?
78
collecting ... [\s]*collected 2 items[\s]*
89
?(?:Submitting tests to SLURM...)?

test/pytest_parallel_refs/terminal_success_0_fail_1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ platform [^\n]*
33
cachedir: [^\n]*
44
?(?:metadata: [^\n]*)?
55
rootdir: [^\n]*
6+
?(?:configfile: [^\n]*)?
67
?(?:plugins: [^\n]*)?
78
collecting ... [\s]*collected 1 item[\s]*
89
?(?:Submitting tests to SLURM...)?

test/pytest_parallel_refs/terminal_two_fail_tests_one_proc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ platform [^\n]*
33
cachedir: [^\n]*
44
?(?:metadata: [^\n]*)?
55
rootdir: [^\n]*
6+
?(?:configfile: [^\n]*)?
67
?(?:plugins: [^\n]*)?
78
collecting ... [\s]*collected 2 items[\s]*
89
?(?:Submitting tests to SLURM...)?

0 commit comments

Comments
 (0)