Skip to content

Commit ab76c67

Browse files
authored
Merge pull request #127 from fastai/typed
change name to ExceptionExpected
2 parents d9891fe + 629a206 commit ab76c67

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

fastcore/_nbdev.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"TEST_IMAGE": "00_test.ipynb",
1818
"TEST_IMAGE_BW": "00_test.ipynb",
1919
"test_fig_exists": "00_test.ipynb",
20-
"TestFail": "00_test.ipynb",
20+
"ExceptionExpected": "00_test.ipynb",
2121
"defaults": "01_foundation.ipynb",
2222
"copy_func": "01_foundation.ipynb",
2323
"patch_to": "01_foundation.ipynb",

fastcore/test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/00_test.ipynb (unless otherwise specified).
22

33
__all__ = ['test_fail', 'test', 'nequals', 'test_eq', 'test_eq_type', 'test_ne', 'is_close', 'test_close', 'test_is',
4-
'test_shuffled', 'test_stdout', 'test_warns', 'TEST_IMAGE', 'TEST_IMAGE_BW', 'test_fig_exists', 'TestFail']
4+
'test_shuffled', 'test_stdout', 'test_warns', 'TEST_IMAGE', 'TEST_IMAGE_BW', 'test_fig_exists',
5+
'ExceptionExpected']
56

67
# Cell
78
from .imports import *
@@ -99,7 +100,7 @@ def test_fig_exists(ax):
99100
assert ax and len(ax.figure.canvas.tostring_argb())
100101

101102
# Cell
102-
class TestFail:
103+
class ExceptionExpected:
103104
"A context manager to allow you to test if an exception (ex) is raised. Optionally, search the exception's error message with a regex."
104105
def __init__(self, ex:Exception, regex:str=None):store_attr()
105106
def __enter__(self): pass

nbs/00_test.ipynb

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

nbs/02_utils.ipynb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@
296296
{
297297
"data": {
298298
"text/plain": [
299-
"<__main__._t at 0x7fbd57805430>"
299+
"<__main__._t at 0x7f4b80d8cf10>"
300300
]
301301
},
302302
"execution_count": null,
@@ -2171,7 +2171,7 @@
21712171
{
21722172
"data": {
21732173
"text/plain": [
2174-
"['h', 'c', 'g', 'd', 'a', 'e', 'b', 'f']"
2174+
"['e', 'a', 'h', 'f', 'g', 'b', 'c', 'd']"
21752175
]
21762176
},
21772177
"execution_count": null,
@@ -3664,7 +3664,7 @@
36643664
"def discount(price:int, pct:float): \n",
36653665
" return (1-pct) * price\n",
36663666
"\n",
3667-
"with TestFail(TypeError): discount(100.0, .1)"
3667+
"with ExceptionExpected(TypeError): discount(100.0, .1)"
36683668
]
36693669
},
36703670
{
@@ -3696,11 +3696,11 @@
36963696
"def foo(a:int, b:str='a'): return a\n",
36973697
"test_eq(foo(1, '2'), 1)\n",
36983698
"\n",
3699-
"with TestFail(TypeError): foo(1,2)\n",
3699+
"with ExceptionExpected(TypeError): foo(1,2)\n",
37003700
"\n",
37013701
"@typed\n",
37023702
"def foo()->str: return 1\n",
3703-
"with TestFail(TypeError): foo()\n",
3703+
"with ExceptionExpected(TypeError): foo()\n",
37043704
"\n",
37053705
"@typed\n",
37063706
"def foo()->str: return '1'\n",
@@ -3964,11 +3964,11 @@
39643964
"name": "stdout",
39653965
"output_type": "stream",
39663966
"text": [
3967-
"1 2020-10-12 21:15:11.361062\n",
3968-
"0 2020-10-12 21:15:11.612469\n",
3969-
"2 2020-10-12 21:15:11.863159\n",
3970-
"3 2020-10-12 21:15:12.113859\n",
3971-
"4 2020-10-12 21:15:12.366331\n"
3967+
"1 2020-10-12 21:48:54.012317\n",
3968+
"0 2020-10-12 21:48:54.265181\n",
3969+
"2 2020-10-12 21:48:54.519284\n",
3970+
"3 2020-10-12 21:48:54.773004\n",
3971+
"4 2020-10-12 21:48:55.026344\n"
39723972
]
39733973
}
39743974
],

0 commit comments

Comments
 (0)