This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Tests for pdb import ~/.pdbrc
Type: enhancement Stage:
Components: Tests Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lukasz.langa, ncoghlan, numerodix, python-dev, r.david.murray, ronaldoussoren, sam.kimbrel, sptonkin, terry.reedy
Priority: normal Keywords: patch

Created on 2013-07-08 05:35 by sptonkin, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pdb_add_readrc_kwarg.diff numerodix, 2013-10-20 17:50 review
18401-pdb-readrc-kwarg-with-docs-and-tests.diff sam.kimbrel, 2014-04-15 19:53 review
Messages (10)
msg192614 - (view) Author: Stephen Tonkin (sptonkin) * Date: 2013-07-08 05:35
After a clean check out and a successful build of Python 3.4, doctests were failing when running test_pdb. Specifically, doctests were failing because they were getting a "*** NameError: name 'execfile' is not defined" when running.

It turns out that my ~/.pdbrc file contained a call to execfile(). While removing this line from my ~/.pdbrc file remedied the issue for me, test_pdb probably shouldn't be reading from global configuration when testing the pdb module.
msg200600 - (view) Author: Martin Matusiak (numerodix) * Date: 2013-10-20 17:50
I have been thinking about a fix for this. A straightforward fix would be to add a kwarg readrc=True to the constructor of Pdb that will default to reading the rc files as it does now, and allows disabling this default. 

The implication is that all tests in stdlib will need to use pdb.Pdb(readrc=False).set_trace() instead of just pdb.set_trace(). This would impact (from what I can see) doctest.py, test_pdb.py and test_doctest.py, and would also require some kind of warning/notice instructing test writers to follow this convention.

I started working on a patch for this (attached), which works for test_pdb, but I can't get the tests in test_doctest to work yet.


It would also be useful to have a test that demonstrates this problem and I'm not sure what the best approach is... should it show that doctests fail? If so, and knowing that Pdb reads rc files from a) $HOME/.pdbrc and b) ./.pdbrc, the test could:
a) unset os.environ['HOME']
b) use a tmpdir and put a temporary .pdbrc file there, with some invalid Python code
c) chdir to that tmpdir

Then to trigger the problem it could write a small script containing a doctest that internally does pdb.set_trace(), run the module and demonstrate that the doctest failed. And then teardown all the temporary resources in a finally block.
msg216188 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-04-14 19:38
Adding a parameter is an enhancement.  Probably not a bad thing to have anyway, but it can only go in 3.5.  Since this isn't something that causes problems for production code, that seems fine.  (The alternative would be to say have a private class variable that the tests would set/reset, but that is pretty ugly).

The final patch will need doc changes and a whatsnew entry.
msg216372 - (view) Author: Sam Kimbrel (sam.kimbrel) * Date: 2014-04-15 19:53
Picked up Martin's patch and added docs, misc/NEWS entry, and a test for readrc=False behavior.
msg216954 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-04-21 17:17
Thanks, Sam.  It is more helpful if the NEWS entry is *not* put in the patch given the current state of the tooling.  What's needs to be added is an entry in Doc/whatsnew/3.5.

For the new test, you can take advantage of the temp_dir and EnvironmentVarGuard helpers in test.support to simplify the code and make it more bullet proof.
msg275570 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-10 05:27
New changeset ee0bbfd972de by Łukasz Langa in branch 'default':
Issue #18401: pdb tests don't read ~/.pdbrc anymore
https://hg.python.org/cpython/rev/ee0bbfd972de
msg275571 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2016-09-10 05:27
Thanks for your contribution, Martin and Sam!
msg275573 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-10 05:57
New changeset 09c730db1aac by Victor Stinner in branch 'default':
Issue #18401: Fix test_pdb if $HOME is not set
https://hg.python.org/cpython/rev/09c730db1aac
msg275575 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-10 06:22
New changeset 5aa77974dd56 by Victor Stinner in branch 'default':
Issue #18401: Fix test_pdb on Windows
https://hg.python.org/cpython/rev/5aa77974dd56
msg275588 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-09-10 07:16
(Copied from my post to python-checkins.)
On Windows, HOME is spelled USERPROFILE or ,HOMEDRIVE + HOMEPATH.  These are set by default on Windows.  The OS specific os.path.expanduser('~') deals with this difference.  I don't know what you are testing exactly, but I believe cross-platform modules should use the latter instead of the *NIX-specific HOME.
History
Date User Action Args
2022-04-11 14:57:47adminsetgithub: 62601
2016-09-10 07:16:31terry.reedysetnosy: + terry.reedy
messages: + msg275588
2016-09-10 06:22:33python-devsetmessages: + msg275575
2016-09-10 05:57:07python-devsetmessages: + msg275573
2016-09-10 05:27:53lukasz.langasetstatus: open -> closed
versions: + Python 3.6, - Python 3.5
nosy: + lukasz.langa

messages: + msg275571

resolution: fixed
2016-09-10 05:27:19python-devsetnosy: + python-dev
messages: + msg275570
2014-04-21 17:17:41r.david.murraysetmessages: + msg216954
2014-04-15 19:53:22sam.kimbrelsetfiles: + 18401-pdb-readrc-kwarg-with-docs-and-tests.diff
nosy: + sam.kimbrel
messages: + msg216372

2014-04-14 19:38:26r.david.murraysetversions: + Python 3.5, - Python 3.4
nosy: + r.david.murray

messages: + msg216188

type: behavior -> enhancement
2013-10-20 17:50:13numerodixsetfiles: + pdb_add_readrc_kwarg.diff

nosy: + numerodix
messages: + msg200600

keywords: + patch
2013-07-08 06:06:33ronaldoussorensetassignee: ronaldoussoren ->
components: - macOS
2013-07-08 05:35:46sptonkincreate