Skip to content

Commit

Permalink
Fixed some tests for Python 3.12 by not relying on Python's built-in …
Browse files Browse the repository at this point in the history
…sum function (PR #6714)

Pull request opened by the merge tool on behalf of #6714
  • Loading branch information
sanderr authored and inmantaci committed Nov 7, 2023
1 parent 666b93f commit f8782c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions changelogs/unreleased/fix-sum-python312.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: "Fixed some tests for Python 3.12 by not relying on Python's built-in sum function"
change-type: patch
destination-branches:
- master
- iso6
12 changes: 7 additions & 5 deletions tests/server/test_environment_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
Contact: code@inmanta.com
"""
import functools
import operator
import uuid
from collections import abc, defaultdict
from collections.abc import AsyncIterator, Sequence
Expand Down Expand Up @@ -801,7 +803,7 @@ async def add_compiles(environment: uuid.UUID, compile_times: abc.Sequence[float
result_timer = await data.EnvironmentMetricsTimer.get_list()

expected_count = len(compile_times)
expected_total_compile_time = sum(compile_times)
expected_total_compile_time = functools.reduce(operator.add, compile_times)

assert len(result_timer) == 1
assert any(
Expand All @@ -828,7 +830,7 @@ async def add_compiles(environment: uuid.UUID, compile_times: abc.Sequence[float
result_timer = await data.EnvironmentMetricsTimer.get_list()

expected_count = len(compile_times)
expected_total_compile_time = sum(compile_times)
expected_total_compile_time = functools.reduce(operator.add, compile_times)

# 1 new entry
assert len(result_timer) == 2
Expand Down Expand Up @@ -943,7 +945,7 @@ async def add_compiles(environment: uuid.UUID, wait_times: abc.Sequence[float]):
result_timer = await data.EnvironmentMetricsTimer.get_list()

expected_count = len(wait_times)
expected_total_wait_time = sum(wait_times)
expected_total_wait_time = functools.reduce(operator.add, wait_times)

assert len(result_timer) == 1
assert any(
Expand All @@ -969,7 +971,7 @@ async def add_compiles(environment: uuid.UUID, wait_times: abc.Sequence[float]):
result_timer = await data.EnvironmentMetricsTimer.get_list()

expected_count = len(wait_times)
expected_total_wait_time = sum(wait_times)
expected_total_wait_time = functools.reduce(operator.add, wait_times)

# 1 new entry
assert len(result_timer) == 2
Expand All @@ -990,7 +992,7 @@ async def add_compiles(environment: uuid.UUID, wait_times: abc.Sequence[float]):
result_timer = await data.EnvironmentMetricsTimer.get_list()

expected_count = len(wait_times)
expected_total_wait_time = sum(wait_times)
expected_total_wait_time = functools.reduce(operator.add, wait_times)

# 1 new entry
assert len(result_timer) == 3
Expand Down

0 comments on commit f8782c6

Please sign in to comment.