getappmap / getappmap/appmap-python

Test Failures in Indico project with AppMap recording enabled

未关闭
#362 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

appmap-python
主要语言
Python
星标
104
派生
17
PR 合并指标
30 天内没有已合并 PR

描述

Appmap library version 2.1.4
Python 3.12.2
Using the Indico fork mailnline branch

The following tests fail when using appmap-python pytest -vv <path to test>

indico/modules/events/export_test.py::test_event_export
============================= test session starts ==============================
platform darwin -- Python 3.12.2, pytest-8.1.1, pluggy-1.4.0 -- /Users/petecheslock/repos/indico/venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/petecheslock/repos/indico
configfile: pytest.ini
plugins: snapshot-0.9.0, cov-5.0.0, indico-3.3.4.dev0, redis-3.0.2, anyio-4.3.0, appmap-2.1.4, mock-3.14.0, localserver-0.8.1
collecting ... collected 1 item

indico/modules/events/export_test.py::test_event_export FAILED           [100%]

=================================== FAILURES ===================================
______________________________ test_event_export _______________________________

db = <IndicoSQLAlchemy postgresql:///test?host=%2Fvar%2Ffolders%2F2y%2Ft_jpbzqd07l4969l1523q2y40000gn%2FT%2Findicotestpg.bcr_yi8e>
dummy_event = <Event(0, 2017-08-24 10:00:00+00:00, 2017-08-24 12:00:00+00:00): "dummy#0">
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x11df6f800>

    @pytest.mark.usefixtures('reproducible_uuids', 'static_indico_version')
    def test_event_export(db, dummy_event, monkeypatch):
        monkeypatch.setattr('indico.modules.events.export.now_utc', lambda: as_utc(datetime(2017, 8, 24, 9, 0, 0)))
    
        f = BytesIO()
        dummy_event.created_dt = as_utc(datetime(2017, 8, 24, 0, 0, 0))
        dummy_event.start_dt = as_utc(datetime(2017, 8, 24, 10, 0, 0))
        dummy_event.end_dt = as_utc(datetime(2017, 8, 24, 12, 0, 0))
    
        s = Session(event=dummy_event, title='sd', is_deleted=True)
        Contribution(event=dummy_event, title='c1', duration=timedelta(minutes=30))
        Contribution(event=dummy_event, title='c2', session=s, duration=timedelta(minutes=30), is_deleted=True)
        db.session.flush()
        export_event(dummy_event, f)
        f.seek(0)
    
        data_yaml_content = (Path(__file__).parent / 'export_test_1.yaml').read_text()
    
        # check composition of tarfile and data.yaml content
>       with tarfile.open(fileobj=f) as tarf:

indico/modules/events/export_test.py:64: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'tarfile.TarFile'>, name = None, mode = 'r'
fileobj = <_io.BytesIO object at 0x11f210d10>, bufsize = 10240, kwargs = {}
not_compressed = <function TarFile.open.<locals>.not_compressed at 0x11efe98a0>
error_msgs = ["- method gz: ReadError('empty file')", "- method bz2: ReadError('not a bzip2 file')", "- method xz: ReadError('not an lzma file')", "- method tar: ReadError('empty file')"]
comptype = 'tar'
func = <bound method TarFile.taropen of <class 'tarfile.TarFile'>>
saved_pos = 0
error_msgs_summary = "- method gz: ReadError('empty file')\n- method bz2: ReadError('not a bzip2 file')\n- method xz: ReadError('not an lzma file')\n- method tar: ReadError('empty file')"

    @classmethod
    def open(cls, name=None, mode="r", fileobj=None, bufsize=RECORDSIZE, **kwargs):
        """Open a tar archive for reading, writing or appending. Return
           an appropriate TarFile class.
    
           mode:
           'r' or 'r:*' open for reading with transparent compression
           'r:'         open for reading exclusively uncompressed
           'r:gz'       open for reading with gzip compression
           'r:bz2'      open for reading with bzip2 compression
           'r:xz'       open for reading with lzma compression
           'a' or 'a:'  open for appending, creating the file if necessary
           'w' or 'w:'  open for writing without compression
           'w:gz'       open for writing with gzip compression
           'w:bz2'      open for writing with bzip2 compression
           'w:xz'       open for writing with lzma compression
    
           'x' or 'x:'  create a tarfile exclusively without compression, raise
                        an exception if the file is already created
           'x:gz'       create a gzip compressed tarfile, raise an exception
                        if the file is already created
           'x:bz2'      create a bzip2 compressed tarfile, raise an exception
                        if the file is already created
           'x:xz'       create an lzma compressed tarfile, raise an exception
                        if the file is already created
    
           'r|*'        open a stream of tar blocks with transparent compression
           'r|'         open an uncompressed stream of tar blocks for reading
           'r|gz'       open a gzip compressed stream of tar blocks
           'r|bz2'      open a bzip2 compressed stream of tar blocks
           'r|xz'       open an lzma compressed stream of tar blocks
           'w|'         open an uncompressed stream for writing
           'w|gz'       open a gzip compressed stream for writing
           'w|bz2'      open a bzip2 compressed stream for writing
           'w|xz'       open an lzma compressed stream for writing
        """
    
        if not name and not fileobj:
            raise ValueError("nothing to open")
    
        if mode in ("r", "r:*"):
            # Find out which *open() is appropriate for opening the file.
            def not_compressed(comptype):
                return cls.OPEN_METH[comptype] == 'taropen'
            error_msgs = []
            for comptype in sorted(cls.OPEN_METH, key=not_compressed):
                func = getattr(cls, cls.OPEN_METH[comptype])
                if fileobj is not None:
                    saved_pos = fileobj.tell()
                try:
                    return func(name, "r", fileobj, **kwargs)
                except (ReadError, CompressionError) as e:
                    error_msgs.append(f'- method {comptype}: {e!r}')
                    if fileobj is not None:
                        fileobj.seek(saved_pos)
                    continue
            error_msgs_summary = '\n'.join(error_msgs)
>           raise ReadError(f"file could not be opened successfully:\n{error_msgs_summary}")
E           tarfile.ReadError: file could not be opened successfully:
E           - method gz: ReadError('empty file')
E           - method bz2: ReadError('not a bzip2 file')
E           - method xz: ReadError('not an lzma file')
E           - method tar: ReadError('empty file')

../../.asdf/installs/python/3.12.2/lib/python3.12/tarfile.py:1809: ReadError
------------------------------ Captured log call -------------------------------
INFO     _appmap.recording:recording.py:104 writing /Users/petecheslock/repos/indico/tmp/appmap/pytest/test_event_export.appmap.json
=========================== short test summary info ============================
FAILED indico/modules/events/export_test.py::test_event_export - tarfile.Read...
============================== 1 failed in 13.20s ==============================

indico/modules/events/export_test.py::test_event_attachment_export
============================= test session starts ==============================
platform darwin -- Python 3.12.2, pytest-8.1.1, pluggy-1.4.0 -- /Users/petecheslock/repos/indico/venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/petecheslock/repos/indico
configfile: pytest.ini
plugins: snapshot-0.9.0, cov-5.0.0, indico-3.3.4.dev0, redis-3.0.2, anyio-4.3.0, appmap-2.1.4, mock-3.14.0, localserver-0.8.1
collecting ... collected 1 item

indico/modules/events/export_test.py::test_event_attachment_export FAILED [100%]

=================================== FAILURES ===================================
_________________________ test_event_attachment_export _________________________

db = <IndicoSQLAlchemy postgresql:///test?host=%2Fvar%2Ffolders%2F2y%2Ft_jpbzqd07l4969l1523q2y40000gn%2FT%2Findicotestpg.8pucq15u>
dummy_event = <Event(0, 2024-07-30 13:42:00+00:00, 2024-07-30 14:42:00+00:00): "dummy#0">

    @pytest.mark.usefixtures('reproducible_uuids', 'dummy_attachment')
    def test_event_attachment_export(db, dummy_event):
        s = Session(event=dummy_event, title='sd', is_deleted=True)
        Contribution(event=dummy_event, title='c1', duration=timedelta(minutes=30))
        Contribution(event=dummy_event, title='c2', session=s, duration=timedelta(minutes=30), is_deleted=True)
        db.session.flush()
    
        f = BytesIO()
        export_event(dummy_event, f)
        f.seek(0)
    
>       with tarfile.open(fileobj=f) as tarf:

indico/modules/events/export_test.py:80: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'tarfile.TarFile'>, name = None, mode = 'r'
fileobj = <_io.BytesIO object at 0x12d13c8b0>, bufsize = 10240, kwargs = {}
not_compressed = <function TarFile.open.<locals>.not_compressed at 0x12cfb1580>
error_msgs = ["- method gz: ReadError('empty file')", "- method bz2: ReadError('not a bzip2 file')", "- method xz: ReadError('not an lzma file')", "- method tar: ReadError('empty file')"]
comptype = 'tar'
func = <bound method TarFile.taropen of <class 'tarfile.TarFile'>>
saved_pos = 0
error_msgs_summary = "- method gz: ReadError('empty file')\n- method bz2: ReadError('not a bzip2 file')\n- method xz: ReadError('not an lzma file')\n- method tar: ReadError('empty file')"

    @classmethod
    def open(cls, name=None, mode="r", fileobj=None, bufsize=RECORDSIZE, **kwargs):
        """Open a tar archive for reading, writing or appending. Return
           an appropriate TarFile class.
    
           mode:
           'r' or 'r:*' open for reading with transparent compression
           'r:'         open for reading exclusively uncompressed
           'r:gz'       open for reading with gzip compression
           'r:bz2'      open for reading with bzip2 compression
           'r:xz'       open for reading with lzma compression
           'a' or 'a:'  open for appending, creating the file if necessary
           'w' or 'w:'  open for writing without compression
           'w:gz'       open for writing with gzip compression
           'w:bz2'      open for writing with bzip2 compression
           'w:xz'       open for writing with lzma compression
    
           'x' or 'x:'  create a tarfile exclusively without compression, raise
                        an exception if the file is already created
           'x:gz'       create a gzip compressed tarfile, raise an exception
                        if the file is already created
           'x:bz2'      create a bzip2 compressed tarfile, raise an exception
                        if the file is already created
           'x:xz'       create an lzma compressed tarfile, raise an exception
                        if the file is already created
    
           'r|*'        open a stream of tar blocks with transparent compression
           'r|'         open an uncompressed stream of tar blocks for reading
           'r|gz'       open a gzip compressed stream of tar blocks
           'r|bz2'      open a bzip2 compressed stream of tar blocks
           'r|xz'       open an lzma compressed stream of tar blocks
           'w|'         open an uncompressed stream for writing
           'w|gz'       open a gzip compressed stream for writing
           'w|bz2'      open a bzip2 compressed stream for writing
           'w|xz'       open an lzma compressed stream for writing
        """
    
        if not name and not fileobj:
            raise ValueError("nothing to open")
    
        if mode in ("r", "r:*"):
            # Find out which *open() is appropriate for opening the file.
            def not_compressed(comptype):
                return cls.OPEN_METH[comptype] == 'taropen'
            error_msgs = []
            for comptype in sorted(cls.OPEN_METH, key=not_compressed):
                func = getattr(cls, cls.OPEN_METH[comptype])
                if fileobj is not None:
                    saved_pos = fileobj.tell()
                try:
                    return func(name, "r", fileobj, **kwargs)
                except (ReadError, CompressionError) as e:
                    error_msgs.append(f'- method {comptype}: {e!r}')
                    if fileobj is not None:
                        fileobj.seek(saved_pos)
                    continue
            error_msgs_summary = '\n'.join(error_msgs)
>           raise ReadError(f"file could not be opened successfully:\n{error_msgs_summary}")
E           tarfile.ReadError: file could not be opened successfully:
E           - method gz: ReadError('empty file')
E           - method bz2: ReadError('not a bzip2 file')
E           - method xz: ReadError('not an lzma file')
E           - method tar: ReadError('empty file')

../../.asdf/installs/python/3.12.2/lib/python3.12/tarfile.py:1809: ReadError
------------------------------ Captured log call -------------------------------
INFO     _appmap.recording:recording.py:104 writing /Users/petecheslock/repos/indico/tmp/appmap/pytest/test_event_attachment_export.appmap.json
=========================== short test summary info ============================
FAILED indico/modules/events/export_test.py::test_event_attachment_export - t...
============================== 1 failed in 13.27s ==============================

indico/modules/events/papers/models/papers_test.py::test_can_judge
============================= test session starts ==============================
platform darwin -- Python 3.12.2, pytest-8.1.1, pluggy-1.4.0 -- /Users/petecheslock/repos/indico/venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/petecheslock/repos/indico
configfile: pytest.ini
plugins: snapshot-0.9.0, cov-5.0.0, indico-3.3.4.dev0, redis-3.0.2, anyio-4.3.0, appmap-2.1.4, mock-3.14.0, localserver-0.8.1
collecting ... collected 1 item

indico/modules/events/papers/models/papers_test.py::test_can_judge FAILED [100%]

=================================== FAILURES ===================================
________________________________ test_can_judge ________________________________

dummy_paper = <Paper(contribution_id=420, state=None)>
dummy_user = <User(1337, 1337@example.test): "Guinea Pig">
dummy_event = <Event(0, 2024-07-30 13:44:00+00:00, 2024-07-30 14:44:00+00:00): "dummy#0">

    @pytest.mark.usefixtures('dummy_contribution')
    def test_can_judge(dummy_paper, dummy_user, dummy_event):
        assert not dummy_paper.can_judge(None)
    
        # Judged papers cannot be judged again
        PaperRevision(paper=dummy_paper, submitter=dummy_user)
>       dummy_paper.state = PaperRevisionState.accepted

indico/modules/events/papers/models/papers_test.py:23: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Paper(contribution_id=420, state=None)>
state = <PaperRevisionState.accepted: 2>

    @state.setter
    def state(self, state):
>       self.last_revision.state = state
E       AttributeError: 'NoneType' object has no attribute 'state'

indico/modules/events/papers/models/papers.py:54: AttributeError
------------------------------ Captured log call -------------------------------
INFO     _appmap.recording:recording.py:104 writing /Users/petecheslock/repos/indico/tmp/appmap/pytest/test_can_judge.appmap.json
=========================== short test summary info ============================
FAILED indico/modules/events/papers/models/papers_test.py::test_can_judge - A...
============================== 1 failed in 12.64s ==============================
indico/util/i18n_test.py::test_lazy_translation
============================= test session starts ==============================
platform darwin -- Python 3.12.2, pytest-8.1.1, pluggy-1.4.0 -- /Users/petecheslock/repos/indico/venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/petecheslock/repos/indico
configfile: pytest.ini
plugins: snapshot-0.9.0, cov-5.0.0, indico-3.3.4.dev0, redis-3.0.2, anyio-4.3.0, appmap-2.1.4, mock-3.14.0, localserver-0.8.1
collecting ... collected 1 item

indico/util/i18n_test.py::test_lazy_translation FAILED                   [100%]

=================================== FAILURES ===================================
____________________________ test_lazy_translation _____________________________

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x12a653860>

    @pytest.mark.usefixtures('mock_translations')
    def test_lazy_translation(monkeypatch):
        monkeypatch.setattr('indico.util.i18n.has_request_context', lambda: False)
        a = _('Fetch the cow')
        b = _('The wheels')
        monkeypatch.setattr('indico.util.i18n.has_request_context', lambda: True)
    
        assert isinstance(a, _LazyString)
        assert isinstance(b, _LazyString)
    
        session.lang = 'fr_CH'
    
>       assert str(a) == 'Fetchez la vache'

indico/util/i18n_test.py:103: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
venv/lib/python3.12/site-packages/speaklater.py:133: in __str__
    return str(self.value)
venv/lib/python3.12/site-packages/speaklater.py:115: in <lambda>
    value = property(lambda x: x._func(*x._args, **x._kwargs))
venv/lib/python3.12/site-packages/_appmap/wrapt/wrappers.py:629: in __call__
    return self._self_wrapper(self.__wrapped__, self._self_instance,
venv/lib/python3.12/site-packages/_appmap/instrument.py:138: in instrumented_fn
    return call_instrumented(f, instance, args, kwargs)
venv/lib/python3.12/site-packages/_appmap/instrument.py:94: in call_instrumented
    ret = f.fn(*args, **kwargs)
indico/util/i18n.py:89: in _indico_gettext
    translations = get_translation_domain(plugin_name).get_translations()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <MockTranslations: "None">

    def __init__(self):
        super().__init__()
>       self._catalog = DICTIONARIES[str(get_locale())]
E       KeyError: 'en_GB'

indico/util/i18n_test.py:63: KeyError
------------------------------ Captured log call -------------------------------
INFO     _appmap.recording:recording.py:104 writing /Users/petecheslock/repos/indico/tmp/appmap/pytest/test_lazy_translation.appmap.json
=========================== short test summary info ============================
FAILED indico/util/i18n_test.py::test_lazy_translation - KeyError: 'en_GB'
============================== 1 failed in 10.39s ==============================

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

针对 indico/modules/events/export_test.py 运行报告中的 appmap-python pytest -vv 命令,重点关注 test_event_exporttest_event_attachment_export。跟踪 tarfile.open 之前的 export_event 调用和 BytesIO 内容;当 AppMap 记录启用时两个测试都能读取导出的 tar 归档,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
testing-qa
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。