Skip to content

Commit

Permalink
Merge remote-tracking branch 'BergLucas/improvement/fix-float-asserti…
Browse files Browse the repository at this point in the history
…ons'
  • Loading branch information
stephanlukasczyk committed Jun 14, 2024
2 parents e2e7710 + f73d23d commit 2febbcb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pynguin/assertion/assertion_to_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,14 @@ def visit_float_assertion(self, assertion: ass.FloatAssertion) -> None:
Args:
assertion: the assertion that is visited.
"""
# Convert the assertion value to a float primitive in case it is a subclass
# of it because Constant nodes in the AST only works with primitives
value = float(assertion.value)
left = au.create_full_name(
self._variable_names, self._module_aliases, assertion.source, load=True
)
comp = self._construct_float_comparator(au.create_ast_constant(assertion.value))
comp = self._construct_float_comparator(au.create_ast_constant(value))
self._assertion_nodes.append(
au.create_ast_assert(au.create_ast_compare(left, ast.Eq(), comp))
)
Expand Down

0 comments on commit 2febbcb

Please sign in to comment.