Skip to content

bpo-31028: Fix test_pydoc when run directly#2864

Merged
vstinner merged 2 commits into
python:masterfrom
vstinner:pydoc_basedir
Jul 27, 2017
Merged

bpo-31028: Fix test_pydoc when run directly#2864
vstinner merged 2 commits into
python:masterfrom
vstinner:pydoc_basedir

Conversation

@vstinner

@vstinner vstinner commented Jul 25, 2017

Copy link
Copy Markdown
Member

Fix get_pydoc_link() of test_pydoc to fix "./python
Lib/test/test_pydoc.py": get the absolute path to file to prevent
relative directories.

https://bugs.python.org/issue31028

Fix get_pydoc_link() of test_pydoc to fix "./python
Lib/test/test_pydoc.py": get the absolute path to __file__ to prevent
relative directories.
@matrixise

Copy link
Copy Markdown
Member

the tests pass on my laptop @serhiy-storchaka

Comment thread Lib/test/test_pydoc.py Outdated
"Returns a documentation web link of a module"
dirname = os.path.dirname
basedir = dirname(dirname(__file__))
basedir = dirname(dirname(os.path.abspath(__file__)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os.path.abspath() doesn't work correctly if the path contains a symlink following by "..".

I would use either os.path.join(os.path.dirname(__file__), os.pardir) or dirname(dirname(os.path.realpath(__file__))).

@vstinner

vstinner commented Jul 25, 2017

Copy link
Copy Markdown
Member Author

@serhiy-storchaka: "I would use either os.path.join(os.path.dirname(__file__), os.pardir) or dirname(dirname(os.path.realpath(__file__)))."

Ok, I changed my PR to use realpath().

@serhiy-storchaka serhiy-storchaka added tests Tests in the Lib/test dir needs backport to 3.6 labels Jul 27, 2017
@vstinner vstinner merged commit fd46561 into python:master Jul 27, 2017
@vstinner vstinner deleted the pydoc_basedir branch July 27, 2017 09:21
@bedevere-bot

Copy link
Copy Markdown

GH-2910 is a backport of this pull request to the 3.6 branch.

@bedevere-bot

Copy link
Copy Markdown

GH-2911 is a backport of this pull request to the 2.7 branch.

vstinner added a commit that referenced this pull request Jul 27, 2017
* bpo-31028: Fix test_pydoc when run directly

Fix get_pydoc_link() of test_pydoc to fix "./python
Lib/test/test_pydoc.py": get the absolute path to __file__ to prevent
relative directories.

* Use realpath() instead of abspath()

(cherry picked from commit fd46561)
vstinner added a commit that referenced this pull request Jul 27, 2017
* bpo-31028: Fix test_pydoc when run directly

Fix get_pydoc_link() of test_pydoc to fix "./python
Lib/test/test_pydoc.py": get the absolute path to __file__ to prevent
relative directories.

* Use realpath() instead of abspath()

(cherry picked from commit fd46561)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants