Skip to content

4.0.2: pytest is failig in test_evm.py with ctypes.ArgumentError #2166

@kloczek

Description

@kloczek

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w --no-isolation
  • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
  • install .whl file in </install/prefix> using 'installer` module
  • run pytest with $PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
  • build is performed in env which is cut off from access to the public network (pytest is executed with -m "not network")

Here is pytest output:

Details
+ cd capstone-4.0.2
+ cd bindings/python
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/capstone-4.0.2-15.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/capstone-4.0.2-15.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.8.18, pytest-7.4.2, pluggy-1.3.0
rootdir: /home/tkloczko/rpmbuild/BUILD/capstone-4.0.2/bindings/python
collected 19 items / 1 error

==================================== ERRORS ====================================
_________________________ ERROR collecting test_evm.py _________________________
/usr/lib/python3.8/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
/usr/lib/python3.8/site-packages/_pytest/runner.py:372: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.8/site-packages/_pytest/python.py:536: in collect
    self._inject_setup_module_fixture()
/usr/lib/python3.8/site-packages/_pytest/python.py:550: in _inject_setup_module_fixture
    self.obj, ("setUpModule", "setup_module")
/usr/lib/python3.8/site-packages/_pytest/python.py:315: in obj
    self._obj = obj = self._getobj()
/usr/lib/python3.8/site-packages/_pytest/python.py:533: in _getobj
    return self._importtestmodule()
/usr/lib/python3.8/site-packages/_pytest/python.py:622: in _importtestmodule
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:567: in import_path
    importlib.import_module(module_name)
/usr/lib64/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1014: in _gcd_import
    ???
<frozen importlib._bootstrap>:991: in _find_and_load
    ???
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:671: in _load_unlocked
    ???
/usr/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:178: in exec_module
    exec(co, module.__dict__)
test_evm.py:11: in <module>
    for i in cs.disasm("\x60\x61\x55", 0x100):
capstone/__init__.py:1058: in disasm
    res = _cs.cs_disasm(self.csh, code, size, offset, count, ctypes.byref(all_insn))
E   ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type
=============================== warnings summary ===============================
capstone/__init__.py:267
  /home/tkloczko/rpmbuild/BUILD/capstone-4.0.2/bindings/python/capstone/__init__.py:267: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
ERROR test_evm.py - ctypes.ArgumentError: argument 2: <class 'TypeError'>: wr...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
========================= 1 warning, 1 error in 0.69s ==========================

Here is list of installed modules in build env

Details
Package            Version
------------------ -------
build              1.0.3
distro             1.8.0
exceptiongroup     1.1.3
gpg                1.21.0
importlib-metadata 6.8.0
iniconfig          2.0.0
installer          0.7.0
libcomps           0.1.19
packaging          23.1
pkg                0.0.0
pluggy             1.3.0
pyproject_hooks    1.0.0
pytest             7.4.2
python-dateutil    2.8.2
setuptools         68.2.2
six                1.16.0
tomli              2.0.1
wheel              0.41.1
zipp               3.16.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions