Skip to content

Commit 9ad5d9d

Browse files
committed
Doc and test what happen when a module load fails
1 parent 1776423 commit 9ad5d9d

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

test/corner_cases.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,32 @@ $ rm -f test/ds/args # byexample: -skip +pass
146146
147147
-->
148148

149+
## Error on module load
150+
151+
Any error loading the module (at the import level) will be shown as any
152+
other error:
153+
154+
```shell
155+
$ byexample -m test/ds/badmod/ -l python --dry docs/languages/python.md
156+
[!] From '/home/user/proj/byexample/test/ds/badmod' loading module 'bogus' failed. Skipping.
157+
invalid syntax (bogus.py, line 1)
158+
<...>
159+
Rerun with -vvv to get a full stack trace.
160+
```
161+
162+
With `-vvv`, the full stack is shown too:
163+
164+
```shell
165+
$ byexample -m test/ds/badmod/ -l python --dry -vvv docs/languages/python.md
166+
[!] From '/home/user/proj/byexample/test/ds/badmod' loading module 'bogus' failed. Skipping.
167+
Traceback (most recent call last):
168+
<...>
169+
File "/home/user/proj/byexample/test/ds/badmod/bogus.py", line 1
170+
<...>
171+
SyntaxError: <...>
172+
<...>
173+
```
174+
149175
## Shutdown
150176

151177
Run three very slow tests and send `byexample` to the background

test/ds/badmod/bogus.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class -not-a-valid-code:
2+
pass

0 commit comments

Comments
 (0)