From c36af744aa18f960425f3ab6dad74be8eff40587 Mon Sep 17 00:00:00 2001 From: Michael Chase <3686226+reallistic@users.noreply.github.com> Date: Wed, 10 Jun 2020 23:14:59 -0700 Subject: [PATCH] speed up tests --- tests/test_collection.py | 7 ++++++- tox.ini | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_collection.py b/tests/test_collection.py index 0ac06c3..d53a697 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -1,4 +1,5 @@ from typing import NamedTuple +from unittest import mock from pyloot import InMemoryBackend from pyloot import PyLoot @@ -16,7 +17,11 @@ def test_collection(): f = Foo(1, 2) MEM_LK_SIM.append(f) pyloot = PyLoot() - pyloot.collect_objects() + with mock.patch( + "pyloot.collector.gc.get_objects", return_value=[f] + ) as mocked_get_objects: + pyloot.collect_objects() + mocked_get_objects.assert_called_once_with() backend: InMemoryBackend = pyloot._backend assert isinstance(backend, InMemoryBackend) objs = backend.fetch() diff --git a/tox.ini b/tox.ini index de8a69d..37d4573 100644 --- a/tox.ini +++ b/tox.ini @@ -17,3 +17,7 @@ commands = coverage report -m coverage html -d .tox/test-reports/{envname}/coverage-html coverage xml -o .tox/test-reports/{envname}/coverage.xml + + +[pytest] +junit_family = xunit2 \ No newline at end of file