From 2fe8ee22c9c4e8d96e0277801fa4f93a3eaca88f Mon Sep 17 00:00:00 2001 From: Matt Wozniski Date: Mon, 5 Jun 2023 20:02:17 -0400 Subject: [PATCH] Fix long test names with xdist (#77) --- src/pytest_memray/plugin.py | 4 ++-- tests/test_pytest_memray.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pytest_memray/plugin.py b/src/pytest_memray/plugin.py index 0bc2bec..e014abf 100644 --- a/src/pytest_memray/plugin.py +++ b/src/pytest_memray/plugin.py @@ -91,7 +91,7 @@ def __init__(self, config: Config) -> None: path: Path | None = config.getvalue("memray_bin_path") self._tmp_dir: None | TemporaryDirectory[str] = None if path is None: - # Check the MEMRAY_RESULT_PAtH environment variable. If this + # Check the MEMRAY_RESULT_PATH environment variable. If this # is set, it means that we are running in a worker and the main # process has set it so we'll use it as the directory to store # the results. @@ -135,7 +135,7 @@ def pytest_pyfunc_call(self, pyfuncitem: Function) -> object | None: return def _build_bin_path() -> Path: - if self._tmp_dir is None: + if self._tmp_dir is None and not os.getenv("MEMRAY_RESULT_PATH"): of_id = pyfuncitem.nodeid.replace("::", "-") of_id = of_id.replace(os.sep, "-") name = f"{self._bin_prefix}-{of_id}.bin" diff --git a/tests/test_pytest_memray.py b/tests/test_pytest_memray.py index bd508a6..0df2e65 100644 --- a/tests/test_pytest_memray.py +++ b/tests/test_pytest_memray.py @@ -470,7 +470,8 @@ def allocating_func2(): allocator.valloc(1024*2) allocator.free() - def test_foo(): + @pytest.mark.parametrize("param", [("unused",)], ids=["x" * 1024]) + def test_foo(param): allocating_func1() def test_bar():