Skip to content

Commit

Permalink
Skip memray tests if not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmlarson committed Apr 23, 2023
1 parent 6346e99 commit 6a208eb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 1 addition & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ trustme
requests
flaky
httpx
memray
pytest-memray
pytest-memray; python_version<"3.12" and sys_platform!="win32" and implementation_name=="cpython"
5 changes: 3 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ def test(session):
session.env["FROZENLIST_NO_EXTENSIONS"] = "1"

session.install("-rdev-requirements.txt", ".")
session.run("pip", "freeze")
memray_supported = not session.run("python", "-c", '"import pytest_memray"')

session.run(
"pytest",
"-v",
"-s",
"-rs",
"--memray",
*("--memray", "--hide-memray-summary") if memray_supported else (),
"--no-flaky-report",
"--max-runs=3",
*(session.posargs or ("tests/",)),
Expand Down
8 changes: 8 additions & 0 deletions tests/test_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@

from .conftest import Server

try:
import pytest_memray # noqa: F401

memray_installed = True
except ImportError:
memray_installed = False


@pytest.mark.skipif(not memray_installed, reason="Memray isn't installed")
@pytest.mark.limit_memory("1MB")
@pytest.mark.asyncio
async def test_memory_limit(server: Server) -> None:
Expand Down

0 comments on commit 6a208eb

Please sign in to comment.