Skip to content

Commit 404405a

Browse files
committed
Better tracemalloc
1 parent f55036d commit 404405a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/conftest.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import argparse
22
import random
33
import time
4-
import tracemalloc
54
from typing import Callable, TypeVar
65
from unittest import mock
76
from unittest.mock import Mock
@@ -78,9 +77,14 @@ def enable_tracemalloc():
7877
"""
7978
Enable tracemalloc while tests are being executed.
8079
"""
81-
tracemalloc.start()
82-
yield
83-
tracemalloc.stop()
80+
try:
81+
import tracemalloc
82+
83+
tracemalloc.start()
84+
yield
85+
tracemalloc.stop()
86+
except ImportError:
87+
yield
8488

8589

8690
def pytest_addoption(parser):

0 commit comments

Comments
 (0)