# How to debug tests with pdb

**URL:** <https://discuss.tryton.org/t/how-to-debug-tests-with-pdb/721>\
**Category:** Developer\
**Created:** [September 12, 2018, 2:40am UTC](https://discuss.tryton.org/t/how-to-debug-tests-with-pdb/721 "2018-09-12T02:40:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincent](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/vincent/32/29_2.png) [@vincent](https://discuss.tryton.org/u/vincent)\
**Post date:** [September 12, 2018, 2:40am UTC](https://discuss.tryton.org/t/how-to-debug-tests-with-pdb/721/1 "2018-09-12T02:40:08Z")

</div>

Is it possible to debug unit tests and scenario tests using pdb and stepping through lines of code and checking variable values?

I know it is possible to run python -m pdb myscript.py on a particular script but is it possible to do this on python setup.py test?

---

<div class="post-metadata">

**Author:** ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)\
**Post date:** [September 12, 2018, 8:32am UTC](https://discuss.tryton.org/t/how-to-debug-tests-with-pdb/721/2 "2018-09-12T08:32:26Z")

</div>

I normally include the lines:

> import pdb; pdb.set\_trace()

On the source code line where I want to start the debugger.  
Then running the test with the normal parameter will launch the debugger when the line is reached.

P.S: If you are on python3.7 you can use the [new breakpoint function](https://hackernoon.com/python-3-7s-new-builtin-breakpoint-a-quick-tour-4f1aebc444c).

---

<div class="post-metadata">

**Author:** ![dabada83](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/dabada83/32/67_2.png) [@dabada83](https://discuss.tryton.org/u/dabada83)\
**Post date:** [September 12, 2018, 3:33pm UTC](https://discuss.tryton.org/t/how-to-debug-tests-with-pdb/721/3 "2018-09-12T15:33:05Z")

</div>

On unit test I also use pdb.  
Can I use pdb to debug scenarios (rst files)?

---

<div class="post-metadata">

**Author:** ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)\
**Post date:** [September 13, 2018, 10:55am UTC](https://discuss.tryton.org/t/how-to-debug-tests-with-pdb/721/4 "2018-09-13T10:55:35Z")

</div>

> [@dabada83](#):
>
> Can I use pdb to debug scenarios (rst files)?

Yes, youe just have to include the same line on the test scenario:

> import pdb; pdb.set\_trace()

If you include on the source code the debugger will be also openend when running the test scenario.
