Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unittest_lint.py fails with IsADirectoryError #4780

Closed
paper42 opened this issue Jul 31, 2021 · 2 comments · Fixed by #4781
Closed

unittest_lint.py fails with IsADirectoryError #4780

paper42 opened this issue Jul 31, 2021 · 2 comments · Fixed by #4781
Labels
Milestone

Comments

@paper42
Copy link
Contributor

paper42 commented Jul 31, 2021

Bug description

https://github.com/PyCQA/pylint/blob/main/tests/lint/unittest_lint.py#L638

try:
    pylintd = join(tempfile.gettempdir(), ".pylint.d")
    os.environ["PYLINTHOME"] = pylintd
    try:
        reload(config)
        assert config.PYLINT_HOME == pylintd
    finally:
        try:
>           os.remove(pylintd)
        except FileNotFoundError:
            pass
finally:
    del os.environ["PYLINTHOME"]

This test fails with IsADirectoryError, because pylintd is a directory. It can be fixed by replacing os.remove with rmtree.

Command used

pytest -k test_pylint_home

Pylint output

_______________________________ test_pylint_home _______________________________

    @pytest.mark.usefixtures("pop_pylintrc")
    def test_pylint_home():
        uhome = os.path.expanduser("~")
        if uhome == "~":
            expected = ".pylint.d"
        else:
            expected = os.path.join(uhome, ".pylint.d")
        assert config.PYLINT_HOME == expected
    
        try:
            pylintd = join(tempfile.gettempdir(), ".pylint.d")
            os.environ["PYLINTHOME"] = pylintd
            try:
                reload(config)
                assert config.PYLINT_HOME == pylintd
            finally:
                try:
>                   os.remove(pylintd)
E                   IsADirectoryError: [Errno 21] Is a directory: '/tmp/.pylint.d'

tests/lint/unittest_lint.py:645: IsADirectoryError

Expected behavior

tests pass

Pylint version

pylint 2.9.6
astroid 2.6.5
Python 3.9.6 (default, Jul  6 2021, 18:29:50) 
[GCC 10.2.1 20201203]

OS / Environment

Void Linux

@paper42 paper42 added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jul 31, 2021
@Pierre-Sassoulas Pierre-Sassoulas removed the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jul 31, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.10.0 milestone Jul 31, 2021
@Pierre-Sassoulas
Copy link
Member

Thank you for the report @paper42 , would you like to contribute the fix as you already analyzed the problem ? :)

@paper42
Copy link
Contributor Author

paper42 commented Jul 31, 2021

sure, #4781

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants