pytest captures stdout, and only prints it if the test fails
Joseph Weston authored on 17/11/2017 12:16:59 • Bas Nijholt committed on 20/11/2017 15:49:57... | ... |
@@ -16,16 +16,16 @@ def run_integrator_learner(f, a, b, tol, nr_points): |
16 | 16 |
return learner |
17 | 17 |
|
18 | 18 |
|
19 |
-def same_ivals(f, a, b, tol, verbose=True): |
|
19 |
+def same_ivals(f, a, b, tol): |
|
20 | 20 |
igral, err, nr_points, ivals = algorithm_4(f, a, b, tol) |
21 | 21 |
|
22 | 22 |
learner = run_integrator_learner(f, a, b, tol, nr_points) |
23 | 23 |
|
24 |
- if verbose: |
|
25 |
- print('igral difference', learner.igral-igral, |
|
26 |
- 'err difference', learner.err - err) |
|
24 |
+ # This will only show up if the test fails, anyway |
|
25 |
+ print('igral difference', learner.igral-igral, |
|
26 |
+ 'err difference', learner.err - err) |
|
27 | 27 |
|
28 |
- return learner.equal(ivals, verbose=verbose) |
|
28 |
+ return learner.equal(ivals, verbose=True) |
|
29 | 29 |
|
30 | 30 |
|
31 | 31 |
def test_cquad(): |
... | ... |
@@ -33,27 +33,26 @@ def test_cquad(): |
33 | 33 |
[f7, 0, 1, 1e-6], |
34 | 34 |
[f21, 0, 1, 1e-3], |
35 | 35 |
[f24, 0, 3, 1e-3]]): |
36 |
- assert same_ivals(*args, verbose=True), 'Function {}'.format(i) |
|
36 |
+ assert same_ivals(*args), 'Function {}'.format(i) |
|
37 | 37 |
|
38 | 38 |
|
39 | 39 |
@pytest.mark.xfail |
40 |
-def test_machine_precision(verbose=True): |
|
40 |
+def test_machine_precision(): |
|
41 | 41 |
f, a, b, tol = [f63, 0, 1, 1e-10] |
42 | 42 |
igral, err, nr_points, ivals = algorithm_4(f, a, b, tol) |
43 | 43 |
|
44 | 44 |
learner = run_integrator_learner(f, a, b, tol, nr_points) |
45 | 45 |
|
46 |
- if verbose: |
|
47 |
- print('igral difference', learner.igral-igral, |
|
48 |
- 'err difference', learner.err - err) |
|
46 |
+ print('igral difference', learner.igral-igral, |
|
47 |
+ 'err difference', learner.err - err) |
|
49 | 48 |
|
50 |
- assert learner.equal(ivals, verbose=verbose) |
|
49 |
+ assert learner.equal(ivals, verbose=True) |
|
51 | 50 |
|
52 | 51 |
|
53 | 52 |
def test_machine_precision2(): |
54 | 53 |
f, a, b, tol = [f63, 0, 1, 1e-10] |
55 | 54 |
igral, err, nr_points, ivals = algorithm_4(f, a, b, tol) |
56 |
- |
|
55 |
+ |
|
57 | 56 |
learner = run_integrator_learner(f, a, b, tol, nr_points) |
58 | 57 |
|
59 | 58 |
np.testing.assert_almost_equal(igral, learner.igral) |