Skip to content

Commit 34ba3d3

Browse files
njzjzpre-commit-ci[bot]Copilot
authored
chore: fix benchmark imports (#2343)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Tests** - Enhanced test coverage to boost reliability by incorporating parameterized testing for module import validation. - Refined the benchmarking approach for command line interface tests, ensuring more consistent performance verification. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 36fa554 commit 34ba3d3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/test_cli.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# SPDX-License-Identifier: LGPL-3.0-or-later
22
"""Tests for the command line interface of the reacnetgenerator package."""
33

4+
import importlib
45
import subprocess
56
import sys
7+
from unittest import mock
68

79
import pytest
810

@@ -18,7 +20,16 @@ def test_module_script():
1820
assert output.splitlines()[0] == f"ReacNetGenerator v{expected_version}"
1921

2022

21-
@pytest.mark.benchmark
2223
def test_cli():
2324
"""Test reacnetgenerator command."""
2425
subprocess.check_output(["reacnetgenerator", "-h"]).decode("ascii")
26+
27+
28+
@pytest.mark.parametrize("mod_name", ["reacnetgenerator.commandline"])
29+
def test_bench_module_import(benchmark, mod_name):
30+
"""Benchmark the import time."""
31+
32+
@benchmark
33+
def _():
34+
with mock.patch("sys.modules", {}):
35+
importlib.import_module(mod_name, "test_bench_imports")

0 commit comments

Comments
 (0)