poetry: Some tests fail because of wrong rights on /foo
-
I am on the latest Poetry version.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option). -
OS version and name: openSUSE/Tumbleweed (Linux)
-
Poetry version: 1.0.0b8
Issue
Plenty of tests fail because of the traceback similar to this one (from ):
[ 88s] ____________________________ test_add_no_constraint ____________________________
[ 88s]
[ 88s] app = <tests.console.conftest.Application object at 0x7fd532dff4a8>
[ 88s] repo = <tests.console.conftest.Repository object at 0x7fd532b587b8>
[ 88s] installer = <poetry.installation.noop_installer.NoopInstaller object at 0x7fd532bc1470>
[ 88s]
[ 88s] def test_add_no_constraint(app, repo, installer):
[ 88s] command = app.find("add")
[ 88s] tester = CommandTester(command)
[ 88s]
[ 88s] repo.add_package(get_package("cachy", "0.1.0"))
[ 88s] repo.add_package(get_package("cachy", "0.2.0"))
[ 88s]
[ 88s] > tester.execute("cachy")
[ 88s]
[ 88s] tests/console/commands/test_add.py:19:
[ 88s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 88s] /usr/lib/python3.7/site-packages/cleo/testers/command_tester.py:61: in execute
[ 88s] self._status_code = command.run(args, self._io)
[ 88s] /usr/lib/python3.7/site-packages/clikit/api/command/command.py:116: in run
[ 88s] return self.handle(self.parse(args), io)
[ 88s] /usr/lib/python3.7/site-packages/clikit/api/command/command.py:120: in handle
[ 88s] status_code = self._do_handle(args, io)
[ 88s] /usr/lib/python3.7/site-packages/clikit/api/command/command.py:163: in _do_handle
[ 88s] self._dispatcher.dispatch(PRE_HANDLE, event)
[ 88s] /usr/lib/python3.7/site-packages/clikit/api/event/event_dispatcher.py:22: in dispatch
[ 88s] self._do_dispatch(listeners, event_name, event)
[ 88s] /usr/lib/python3.7/site-packages/clikit/api/event/event_dispatcher.py:89: in _do_dispatch
[ 88s] listener(event, event_name, self)
[ 88s] poetry/console/config/application_config.py:86: in set_env
[ 88s] env = env_manager.create_venv(io)
[ 88s] poetry/utils/env.py:587: in create_venv
[ 88s] self.build_venv(str(venv), executable=executable)
[ 88s] poetry/utils/env.py:647: in build_venv
[ 88s] build(path)
[ 88s] /usr/lib64/python3.7/venv/__init__.py:60: in create
[ 88s] context = self.ensure_directories(env_dir)
[ 88s] /usr/lib64/python3.7/venv/__init__.py:107: in ensure_directories
[ 88s] create_if_needed(env_dir)
[ 88s] /usr/lib64/python3.7/venv/__init__.py:96: in create_if_needed
[ 88s] os.makedirs(d)
[ 88s] /usr/lib64/python3.7/os.py:211: in makedirs
[ 88s] makedirs(head, exist_ok=exist_ok)
[ 88s] /usr/lib64/python3.7/os.py:211: in makedirs
[ 88s] makedirs(head, exist_ok=exist_ok)
[ 88s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 88s]
[ 88s] name = '/foo', mode = 511, exist_ok = False
[ 88s]
[ 88s] def makedirs(name, mode=0o777, exist_ok=False):
[ 88s] """makedirs(name [, mode=0o777][, exist_ok=False])
[ 88s]
[ 88s] Super-mkdir; create a leaf directory and all intermediate ones. Works like
[ 88s] mkdir, except that any intermediate path segment (not just the rightmost)
[ 88s] will be created if it does not exist. If the target directory already
[ 88s] exists, raise an OSError if exist_ok is False. Otherwise no exception is
[ 88s] raised. This is recursive.
[ 88s]
[ 88s] """
[ 88s] head, tail = path.split(name)
[ 88s] if not tail:
[ 88s] head, tail = path.split(head)
[ 88s] if head and tail and not path.exists(head):
[ 88s] try:
[ 88s] makedirs(head, exist_ok=exist_ok)
[ 88s] except FileExistsError:
[ 88s] # Defeats race condition when another thread created the path
[ 88s] pass
[ 88s] cdir = curdir
[ 88s] if isinstance(tail, bytes):
[ 88s] cdir = bytes(curdir, 'ASCII')
[ 88s] if tail == cdir: # xxx/newdir/. exists if xxx/newdir exists
[ 88s] return
[ 88s] try:
[ 88s] > mkdir(name, mode)
[ 88s] E PermissionError: [Errno 13] Permission denied: '/foo'
[ 88s]
[ 88s] /usr/lib64/python3.7/os.py:221: PermissionError
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 53 (31 by maintainers)
Commits related to this issue
- tests: cleanup cache and http usage - ensure tests rely on temporary cache directory - remove external http call requirement for lock --no-update Relates-to: #1645 — committed to abn/poetry by abn 4 years ago
- tests: cleanup cache and http usage - ensure tests rely on temporary cache directory - remove external http call requirement for lock --no-update Relates-to: #1645 — committed to abn/poetry by abn 4 years ago
- tests: cleanup cache and http usage - ensure tests rely on temporary cache directory - remove external http call requirement for lock --no-update Relates-to: #1645 — committed to python-poetry/poetry by abn 4 years ago
From the package maintainers’ point of view running the test suite using the system interpreter (and not in the virtual environment) is exactly what you want to do. This way you can test whether the software behaves correctly under the exact Python version that is currently packaged with all needed dependencies (that often have some downstream patches).
Eli by using arguments like
--system-site-packages
and--without-pip
is effectively trying to create a virtual environment that behaves like there was none.Why is this bug report closed just because some unrelated bug mentioned 6 comments in happens to be resolved?
The error seems to have moved around a bit, but I still cannot package poetry due to:
Here is an example where #3255 and #3107 (added some additional fixes to support these cases) are applied, without a virtualenvironment and test run by an unprivileged user.
Using alpine as the example since I am guessing that is the one with build failures still based on above comments.
The project test suite is not necessarily developed with distro packaging requirements in mind, but rather with the intent to test the project’s functional requirements. What this means is that certain assumptions about how it is run might have crept in that might not work within the a distro’s package build environment. The test suite, for example, tries to assess that the system interpreter (which to poetry is the interpretor that starts poetry) site can be modified and a script can be installed in it’s prefix (side-effect of another test case that installs a package as a pre-requisite). However, note that this is a functional test, and the failure is expected when the test suite is run with a user that does not have the privilege to modify the site - as will the real world scenario.
I am not suggesting that this cannot be improved. However, we do not, at this time, have the resources/bandwidth to ensure that the test suite itself works outside the current recommended development environment. We would definitely appreciate pull requests to make the situation better as these build environments are not readily accessible for us. Things might also get better with #3107 and #3255.
That’s the info we needed! 🎉
This works:
I discovered the cause of this error when modifying this: https://github.com/python-poetry/poetry/blob/68d6939f2e9cac1178fc5ffbcc3bac7a9db43fce/tests/installation/test_executor.py#L98-L126
so the
assert 0 == executor.execute
no longer masked the output which is tested by:assert expected == output
I have added some cleanup for the tests suites so that they work better for the use cases being described above. I am assuming (since it is not entirely clear), that the environments are your typical distro packaging environments. #3255
@bnavigator this should allow you to re-enable most of those tests. Please let me know if additional tests are still failining. Particularly, if any tests still require pypi access or if data is written to non temporary directories.
Regarding the use of dephell, I am quite curious as to why this is being used for building a PEP 517 package. Sounds like it introduces more problems than what it solves.
I’d also urge that the coversation be kept constructive.