pdb doesn't play nice with doctests.. this is a quick hack to fix that.
Project description
What does it do? Fixes line numbers so you can easily figure out where your doctest is failing, also fixes
the list command in pdb so it can properly list the source code for your doctest.
Other things may be broken so please send feedback.
add to your $HOME/.pdbrc:
import doctestpdbhacks
Here's an example of what it does:
$ cat doctesttest.py
def foo(a):
"""
>>> foo(1)
2
>>> import pdb; pdb.set_trace()
>>> foo(2)
2
"""
return a + 1
def _test():
import doctest
doctest.testmod()
if __name__ == "__main__":
_test()
# without doctestpdbhacks
$ python doctesttest.py
> <doctest __main__.foo[1]>(1)?()->None
-> import pdb; pdb.set_trace()
(Pdb) l
1 -> import pdb; pdb.set_trace()
[EOF]
# Turn on doctestpdbhacks:
$ echo >>$HOME/.pdbrc "import doctestpdbhacks"
$ python doctesttest.py
--Return--
> doctest @ doctesttest.py(5)?()->None
-> >>> import pdb; pdb.set_trace()
(Pdb) l
1 def foo(a):
2 """
3 >>> foo(1)
4 2
5 -> >>> import pdb; pdb.set_trace()
6 >>> foo(2)
7 2
8 """
9 return a + 1
10
11 def _test():
the list command in pdb so it can properly list the source code for your doctest.
Other things may be broken so please send feedback.
add to your $HOME/.pdbrc:
import doctestpdbhacks
Here's an example of what it does:
$ cat doctesttest.py
def foo(a):
"""
>>> foo(1)
2
>>> import pdb; pdb.set_trace()
>>> foo(2)
2
"""
return a + 1
def _test():
import doctest
doctest.testmod()
if __name__ == "__main__":
_test()
# without doctestpdbhacks
$ python doctesttest.py
> <doctest __main__.foo[1]>(1)?()->None
-> import pdb; pdb.set_trace()
(Pdb) l
1 -> import pdb; pdb.set_trace()
[EOF]
# Turn on doctestpdbhacks:
$ echo >>$HOME/.pdbrc "import doctestpdbhacks"
$ python doctesttest.py
--Return--
> doctest @ doctesttest.py(5)?()->None
-> >>> import pdb; pdb.set_trace()
(Pdb) l
1 def foo(a):
2 """
3 >>> foo(1)
4 2
5 -> >>> import pdb; pdb.set_trace()
6 >>> foo(2)
7 2
8 """
9 return a + 1
10
11 def _test():
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
doctestpdbhacks-0.1.tar.gz
(2.1 kB
view details)
Built Distribution
File details
Details for the file doctestpdbhacks-0.1.tar.gz
.
File metadata
- Download URL: doctestpdbhacks-0.1.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 251bbcb990410da79574872c5ffb3d15969ad8b3d49939bbe3ea26a60dfb2440 |
|
MD5 | 25c65a4dcdcd286030c8908a67c842fb |
|
BLAKE2b-256 | 31ce07efb065a26509f5d9dcac858354bc25614c327958de159f8ee72f3acd07 |
File details
Details for the file doctestpdbhacks-0.1-py2.4.egg
.
File metadata
- Download URL: doctestpdbhacks-0.1-py2.4.egg
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6f8adf403e57fd8e5a1652879cfe6eb33184c618b6153cac7861e92f1189794 |
|
MD5 | 43735f3a07cf93a854d7fa0a6ffa30b2 |
|
BLAKE2b-256 | db8934eae121b8ccd2ad0cf97d10bed6c87fdab150d18aaad8ba3d12e86e4cb7 |