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

tests/test_posix.py::test_get_shell[mapping0-result0] fails with 1.5.2+ #80

Closed
mgorny opened this issue Aug 17, 2023 · 1 comment · Fixed by #82
Closed

tests/test_posix.py::test_get_shell[mapping0-result0] fails with 1.5.2+ #80

mgorny opened this issue Aug 17, 2023 · 1 comment · Fixed by #82

Comments

@mgorny
Copy link

mgorny commented Aug 17, 2023

$ python -m pytest
========================================================= test session starts =========================================================
platform linux -- Python 3.11.4, pytest-7.4.0, pluggy-1.2.0
rootdir: /tmp/shellingham
plugins: mock-3.11.1
collected 1 item                                                                                                                      

tests/test_posix.py F                                                                                                           [100%]

============================================================== FAILURES ===============================================================
__________________________________________________ test_get_shell[mapping0-result0] ___________________________________________________

mocker = <pytest_mock.plugin.MockerFixture object at 0x7f928f57d8d0>, environ = <test_posix.EnvironManager object at 0x7f9290491550>
mapping = {'1480': Process(args=('/Applications/iTerm.app/Contents/MacOS/iTerm2', '--server', 'login', '-fp', 'keegan'), pid='14...s=('screen',), pid='1556', ppid='1482'), '1558': Process(args=('-/usr/local/bin/bash',), pid='1558', ppid='1557'), ...}
result = ('bash', '==MOCKED=LOGIN=SHELL==/bash')

    @pytest.mark.parametrize('mapping, result', [
        (   # Based on pypa/pipenv#2496, provided by @keegancsmith.
            MAPPING_EXAMPLE_KEEGANCSMITH, ('bash', '==MOCKED=LOGIN=SHELL==/bash'),
        ),
    ])
    def test_get_shell(mocker, environ, mapping, result):
        environ.patch(SHELL='==MOCKED=LOGIN=SHELL==/bash')
>       mocker.patch.object(posix, '_get_process_mapping', return_value=mapping)

tests/test_posix.py:86: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.venv/lib/python3.11/site-packages/pytest_mock/plugin.py:255: in object
    return self._start_patch(
.venv/lib/python3.11/site-packages/pytest_mock/plugin.py:220: in _start_patch
    mocked: MockType = p.start()
/usr/lib/python3.11/unittest/mock.py:1591: in start
    result = self.__enter__()
/usr/lib/python3.11/unittest/mock.py:1443: in __enter__
    original, local = self.get_original()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <unittest.mock._patch object at 0x7f928f5cb850>

    def get_original(self):
        target = self.getter()
        name = self.attribute
    
        original = DEFAULT
        local = False
    
        try:
            original = target.__dict__[name]
        except (AttributeError, KeyError):
            original = getattr(target, name, DEFAULT)
        else:
            local = True
    
        if name in _builtins and isinstance(target, ModuleType):
            self.create = True
    
        if not self.create and original is DEFAULT:
>           raise AttributeError(
                "%s does not have the attribute %r" % (target, name)
            )
E           AttributeError: <module 'shellingham.posix' from '/tmp/shellingham/.venv/lib/python3.11/site-packages/shellingham/posix/__init__.py'> does not have the attribute '_get_process_mapping'

/usr/lib/python3.11/unittest/mock.py:1416: AttributeError
======================================================= short test summary info =======================================================
FAILED tests/test_posix.py::test_get_shell[mapping0-result0] - AttributeError: <module 'shellingham.posix' from '/tmp/shellingham/.venv/lib/python3.11/site-packages/shellingham/posix/__init__.p...
========================================================== 1 failed in 0.16s ==========================================================

This is on Gentoo Linux amd64, Python 3.11.4, shellingham 1.5.3 (b8ba512).

bisect blames 7bf9e76. Indeed, it seems that _get_process_mapping() was removed there.

Also, it seems that CI doesn't actually run tests, since only test env runs tests, and CI runs all the other envs that apparently only install the package.

@mgorny mgorny changed the title tests/test_posix.py::test_get_shell[mapping0-result0] fails with 1.5.3 tests/test_posix.py::test_get_shell[mapping0-result0] fails with 1.5.2+ Aug 17, 2023
@dutyrok
Copy link

dutyrok commented Sep 13, 2023

Hello, I has got this error on ALT Linux Sisyphus (Python 3.11.4) too. Will the issue be fixed?

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

Successfully merging a pull request may close this issue.

2 participants