Skip to content

.testmondata does not get flushed at exit #233

@szym

Description

@szym

What is your setup and what steps did you do?

The easiest way to reproduce is to run pytest --testmon in an environment that has:
pytest==8.2.2
pytest-mock==3.14.0
pytest-testmon==2.1.1

I tried to make it even smaller and found that this reduced part of pytest-mock is enough to cause trouble:

from dataclasses import dataclass
from typing import Iterator

@dataclass
class Foo: pass

T = Iterator[Foo]

What was the outcome?
Once this code is loaded by pytest, it no longer deletes the instance of TestmonData and consequently its db (apparently, Python does not promise __del__ will ever be called unless an instance is explicitly deleted). In result, the sqlite connection is not flushed. The .testmondata will still recover on the next run, but when trying to archive it (as part of CI), it makes a bit frustrating to have to carry its -wal and -shm files as well.

What did you expect instead?
.testmondata to be flushed. Probably simplest to makeTestmonData.close_connection() explicitly close the sqlite3 connection.

What is your operating system and it's version please?
macOS 11.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions