Skip to content

Commit

Permalink
Fix benchmarks imports for Python 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
hgrecco committed Jul 15, 2023
1 parent 3e0a840 commit 20d18ba
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pint/testsuite/benchmarks/test_10_registry.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pytest

import pathlib
from typing import Any, TypeVar, Callable, TypeAlias
from typing import Any, TypeVar, Callable

from ...compat import TypeAlias

import pint

Expand Down Expand Up @@ -48,7 +50,7 @@ def test_build_cache(setup: SetupType, benchmark):

@pytest.mark.parametrize("key", UNITS)
@pytest.mark.parametrize("pre_run", (True, False))
def test_getattr(benchmark, setup: SetupType, key, pre_run):
def test_getattr(benchmark, setup: SetupType, key: str, pre_run: bool):
ureg, _ = setup
if pre_run:
no_benchmark(getattr, ureg, key)
Expand All @@ -57,7 +59,7 @@ def test_getattr(benchmark, setup: SetupType, key, pre_run):

@pytest.mark.parametrize("key", UNITS)
@pytest.mark.parametrize("pre_run", (True, False))
def test_getitem(benchmark, setup: SetupType, key, pre_run):
def test_getitem(benchmark, setup: SetupType, key: str, pre_run: bool):
ureg, _ = setup
if pre_run:
no_benchmark(getitem, ureg, key)
Expand All @@ -66,7 +68,7 @@ def test_getitem(benchmark, setup: SetupType, key, pre_run):

@pytest.mark.parametrize("key", UNITS)
@pytest.mark.parametrize("pre_run", (True, False))
def test_parse_unit_name(benchmark, setup: SetupType, key, pre_run):
def test_parse_unit_name(benchmark, setup: SetupType, key: str, pre_run: bool):
ureg, _ = setup
if pre_run:
no_benchmark(ureg.parse_unit_name, key)
Expand All @@ -75,15 +77,15 @@ def test_parse_unit_name(benchmark, setup: SetupType, key, pre_run):

@pytest.mark.parametrize("key", UNITS)
@pytest.mark.parametrize("pre_run", (True, False))
def test_parse_units(benchmark, setup: SetupType, key, pre_run):
def test_parse_units(benchmark, setup: SetupType, key: str, pre_run: bool):
ureg, _ = setup
if pre_run:
no_benchmark(ureg.parse_units, key)
benchmark(ureg.parse_units, key)


@pytest.mark.parametrize("key", UNITS)
def test_parse_expression(benchmark, setup: SetupType, key, pre_run):
def test_parse_expression(benchmark, setup: SetupType, key: str, pre_run: bool):
ureg, _ = setup
if pre_run:
no_benchmark(ureg.parse_expression, "1.0 " + key)
Expand Down Expand Up @@ -121,7 +123,7 @@ def test_to_units_container_detached(benchmark, setup: SetupType, unit, pre_run)
"key", (("uc_meter", "uc_kilometer"), ("uc_kilometer/second", "uc_angstrom/minute"))
)
@pytest.mark.parametrize("pre_run", (True, False))
def test_convert_from_uc(benchmark, my_setup: SetupType, key, pre_run):
def test_convert_from_uc(benchmark, my_setup: SetupType, key: str, pre_run: bool):
src, dst = key
ureg, data = my_setup
if pre_run:
Expand Down

0 comments on commit 20d18ba

Please sign in to comment.