$ 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 (b8ba512b6f53807416fa446ccec295c79131cc76).
bisect blames 7bf9e76accdf6e9e92f8e27f9c9341e47ea8489d. 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.
This is on Gentoo Linux amd64, Python 3.11.4, shellingham 1.5.3 (b8ba512b6f53807416fa446ccec295c79131cc76).
bisect blames 7bf9e76accdf6e9e92f8e27f9c9341e47ea8489d. 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.