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

PermissionError: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/guidata/tests/data/genreqs/requirements.rst' #70

Closed
picca opened this issue Mar 12, 2024 · 3 comments

Comments

@picca
Copy link
Collaborator

picca commented Mar 12, 2024

Hello, while preparing the Debian package of guidata, I got this failure.

110s =================================== FAILURES ===================================
110s _______________________ test_generate_requirement_tables _______________________
110s 
110s     def test_generate_requirement_tables():
110s         """Test generate_requirement_tables."""
110s >       genreqs.gen_path_req_rst(GR_PATH, "guidata", ["Python>=3.8", "PyQt>=5.11"], GR_PATH)
110s 
110s tests/unit/test_genreqs.py:23: 
110s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
110s 
110s path = '/usr/lib/python3/dist-packages/guidata/tests/data/genreqs'
110s modname = 'guidata', additional_reqs = ['Python>=3.8', 'PyQt>=5.11']
110s destpath = '/usr/lib/python3/dist-packages/guidata/tests/data/genreqs'
110s 
110s     def gen_path_req_rst(
110s         path: str, modname: str, additional_reqs: list[str], destpath: str | None = None
110s     ) -> None:
110s         """Generate install 'requirements.rst' reStructuredText text.
110s         This reStructuredText text is written in a file which is by default located in
110s         the `doc` folder of the module.
110s     
110s         Args:
110s             path (str): Path to folder containing pyproject.toml or setup.cfg file
110s             modname (str): Module name
110s             additional_reqs (list[str]): Additional requirements
110s             destpath (str): Destination path for requirements.rst file (optional).
110s         """
110s         requirements = extract_requirements_from_toml(path)
110s         if requirements is None:
110s             requirements = extract_requirements_from_cfg(path)
110s         if requirements is None:
110s             raise RuntimeError(
110s                 "Could not find pyproject.toml or setup.cfg file in %s" % path
110s             )
110s         requirements = extract_requirements_from_toml(path)
110s         if requirements is None:
110s             requirements = extract_requirements_from_cfg(path)
110s         if requirements is None:
110s             raise RuntimeError(
110s                 "Could not find pyproject.toml or setup.cfg file in %s" % path
110s             )
110s         text = f"""The :mod:`{modname}` package requires the following Python modules:
110s     
110s     {reqlist_to_table(requirements["main"]+additional_reqs)}"""
110s         for category, title in (
110s             ("dev", "development"),
110s             ("doc", "building the documentation"),
110s             ("test", "running test suite"),
110s         ):
110s             if category in requirements:
110s                 text += f"""
110s     
110s     Optional modules for {title}:
110s     
110s     {reqlist_to_table(requirements[category])}"""
110s         if destpath is None:
110s             destpath = osp.join(path, "doc")
110s >       with open(osp.join(destpath, "requirements.rst"), "w") as fdesc:
110s E       PermissionError: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/guidata/tests/data/genreqs/requirements.rst'
110s 
110s /usr/lib/python3/dist-packages/guidata/utils/genreqs.py:192: PermissionError

During the test it tries to write some file in a non writable location.

here the command executed for the tests.

Test-Command: set -efu
 ; export GUIDATA_UNATTENDED_TESTS=1
 ; export HOME="$AUTOPKGTEST_TMP"
 ; cp -r guidata/tests "$AUTOPKGTEST_TMP"
 ; for py in $(py3versions -r 2>/dev/null)
 ; do cd "$AUTOPKGTEST_TMP"
 ; echo "Testing with $py:"
 ; $py -m pytest tests
 ; done
@PierreRaybaut
Copy link
Collaborator

Thanks for the feedback Fred ;-)

I was about to release a critical bug fix (V3.4.1).
So I'm also fixing this right now: in fact this test should not be executed within the test suite (it should be executed manually for development purpose).

@PierreRaybaut
Copy link
Collaborator

PierreRaybaut commented Mar 12, 2024

@picca : FYI, just released V3.4.1

@picca
Copy link
Collaborator Author

picca commented Mar 12, 2024 via email

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

No branches or pull requests

2 participants