1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-11-18 12:23:48 +03:00

tests: use mocks to allow calling virEventRegisterImpl many times

We currently have to run each of the test_aio.py test cases in a
separate process, because libvirt.virEventRegisterImpl can only be
called once per process. This leads to quite unpleasant console
output when running tests.

By introducing a mock for libvirt.virEventRegisterImpl we can
regain the ability to run everything in a single process. The only
caveat is that it relies on tests to fully cleanup, but in practice
this is ok for our current tests.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé
2022-05-17 15:01:19 +01:00
parent b9f79758c9
commit e3fab09382
4 changed files with 102 additions and 25 deletions

View File

@@ -310,19 +310,7 @@ class my_test(Command):
os.environ["PYTHONPATH"] = self.build_platlib
pytest = self.find_pytest_path()
# Run the normal tests.
subprocess.check_call([pytest, "-m", "not separate_process"])
# Run the tests that require their own process.
testlist = subprocess.run(
[pytest, "--collect-only", "--quiet", "-m", "separate_process"],
check=True, stdout=subprocess.PIPE)
testlist = testlist.stdout.decode("utf-8").splitlines()
testlist = filter(
lambda test: test and "tests collected" not in test, testlist)
for test in testlist:
subprocess.check_call([pytest, test])
subprocess.check_call([pytest])
class my_clean(Command):
def run(self):