|
6 | 6 | (deliberately, just to see how it goes). |
7 | 7 | """ |
8 | 8 |
|
| 9 | +import pytest |
| 10 | +from IPython.lib.pretty import pretty |
| 11 | + |
9 | 12 | from example_fgen_basic.error_v import ErrorV |
10 | 13 | from example_fgen_basic.error_v.creation import create_error |
11 | 14 |
|
@@ -38,10 +41,40 @@ def test_create_error_negative(): |
38 | 41 | assert res.message == "Negative number supplied" |
39 | 42 |
|
40 | 43 |
|
41 | | -# Tests to write: |
42 | | -# - if we create more errors than we have available, we don't segfault. |
43 | | -# Instead, we should get an error back. |
44 | | -# That error should just use the instance ID of the last available array index |
45 | | -# (it is ok to overwrite an already used error to avoid a complete failure, |
46 | | -# but we should probably include that we did this in the error message). |
47 | | -# - we can resize the available number of error instances to avoid hitting limits |
| 44 | +def test_error_too_many_instances(): |
| 45 | + pytest.skip("Causes segfault right now") |
| 46 | + # - if we create more errors than we have available, we don't segfault. |
| 47 | + # Instead, we should get an error back. |
| 48 | + # That error should just use the instance ID of the last available array index |
| 49 | + # (it is ok to overwrite an already used error to avoid a complete failure, |
| 50 | + # but we should probably include that we did this in the error message). |
| 51 | + # TODO: expect error here |
| 52 | + for _ in range(4097): |
| 53 | + create_error(1) |
| 54 | + |
| 55 | + |
| 56 | +def test_increase_number_of_instances(): |
| 57 | + raise NotImplementedError |
| 58 | + # - Make 4096 instances |
| 59 | + # - show that making one more raises an error |
| 60 | + # - increase number of instances |
| 61 | + # - show that making one more now works without error |
| 62 | + |
| 63 | + |
| 64 | +# Some test to illustrate what the formatting does |
| 65 | +def test_error_str(file_regression): |
| 66 | + res = create_error(1.0) |
| 67 | + |
| 68 | + file_regression.check(str(res)) |
| 69 | + |
| 70 | + |
| 71 | +def test_error_pprint(file_regression): |
| 72 | + res = create_error(1.0) |
| 73 | + |
| 74 | + file_regression.check(pretty(res)) |
| 75 | + |
| 76 | + |
| 77 | +def test_error_html(file_regression): |
| 78 | + res = create_error(1.0) |
| 79 | + |
| 80 | + file_regression.check(res._repr_html_(), extension=".html") |
0 commit comments