Skip to content

test_future_import asserts due to result_lines returning 2.3999999999999999 and not 2.4 #408

Closed

Description

@RossComputerGuy
=================================== FAILURES ===================================
________________________ FuturesTest.test_future_import ________________________
Traceback (most recent call last):
  File "/nix/store/lfj9h46jsidlg7mg4yy33rspmls6a046-python3.12-pytest-8.2.2-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/_pytest/runner.py", line 341, in from_call
    result: Optional[TResult] = func()
                                ^^^^^^
  File "/nix/store/lfj9h46jsidlg7mg4yy33rspmls6a046-python3.12-pytest-8.2.2-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/_pytest/runner.py", line 241, in <lambda>
    lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/130vq5jz29v89na1hj9x2kgkhlj3ysbc-python3.12-pluggy-1.5.0-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/130vq5jz29v89na1hj9x2kgkhlj3ysbc-python3.12-pluggy-1.5.0-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/130vq5jz29v89na1hj9x2kgkhlj3ysbc-python3.12-pluggy-1.5.0-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/nix/store/130vq5jz29v89na1hj9x2kgkhlj3ysbc-python3.12-pluggy-1.5.0-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lfj9h46jsidlg7mg4yy33rspmls6a046-python3.12-pytest-8.2.2-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/_pytest/threadexception.py", line 87, in pytest_runtest_call
    yield from thread_exception_runtest_hook()
  File "/nix/store/lfj9h46jsidlg7mg4yy33rspmls6a046-python3.12-pytest-8.2.2-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/_pytest/threadexception.py", line 63, in thread_exception_runtest_hook
    yield
  File "/nix/store/130vq5jz29v89na1hj9x2kgkhlj3ysbc-python3.12-pluggy-1.5.0-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lfj9h46jsidlg7mg4yy33rspmls6a046-python3.12-pytest-8.2.2-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/_pytest/unraisableexception.py", line 90, in pytest_runtest_call
    yield from unraisable_exception_runtest_hook()
  File "/nix/store/lfj9h46jsidlg7mg4yy33rspmls6a046-python3.12-pytest-8.2.2-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/_pytest/unraisableexception.py", line 65, in unraisable_exception_runtest_hook
    yield
  File "/nix/store/130vq5jz29v89na1hj9x2kgkhlj3ysbc-python3.12-pluggy-1.5.0-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lfj9h46jsidlg7mg4yy33rspmls6a046-python3.12-pytest-8.2.2-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/_pytest/logging.py", line 850, in pytest_runtest_call
    yield from self._runtest_for(item, "call")
  File "/nix/store/lfj9h46jsidlg7mg4yy33rspmls6a046-python3.12-pytest-8.2.2-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/_pytest/logging.py", line 833, in _runtest_for
    yield
  File "/nix/store/130vq5jz29v89na1hj9x2kgkhlj3ysbc-python3.12-pluggy-1.5.0-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lfj9h46jsidlg7mg4yy33rspmls6a046-python3.12-pytest-8.2.2-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/_pytest/capture.py", line 878, in pytest_runtest_call
    return (yield)
            ^^^^^
  File "/nix/store/130vq5jz29v89na1hj9x2kgkhlj3ysbc-python3.12-pluggy-1.5.0-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/pluggy/_callers.py", line 122, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lfj9h46jsidlg7mg4yy33rspmls6a046-python3.12-pytest-8.2.2-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/_pytest/skipping.py", line 257, in pytest_runtest_call
    return (yield)
            ^^^^^
  File "/nix/store/130vq5jz29v89na1hj9x2kgkhlj3ysbc-python3.12-pluggy-1.5.0-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lfj9h46jsidlg7mg4yy33rspmls6a046-python3.12-pytest-8.2.2-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/_pytest/runner.py", line 183, in pytest_runtest_call
    raise e
  File "/nix/store/lfj9h46jsidlg7mg4yy33rspmls6a046-python3.12-pytest-8.2.2-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/_pytest/runner.py", line 173, in pytest_runtest_call
    item.runtest()
  File "/nix/store/lfj9h46jsidlg7mg4yy33rspmls6a046-python3.12-pytest-8.2.2-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/_pytest/python.py", line 1632, in runtest
    self.ihook.pytest_pyfunc_call(pyfuncitem=self)
  File "/nix/store/130vq5jz29v89na1hj9x2kgkhlj3ysbc-python3.12-pluggy-1.5.0-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/130vq5jz29v89na1hj9x2kgkhlj3ysbc-python3.12-pluggy-1.5.0-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/130vq5jz29v89na1hj9x2kgkhlj3ysbc-python3.12-pluggy-1.5.0-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/pluggy/_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/nix/store/130vq5jz29v89na1hj9x2kgkhlj3ysbc-python3.12-pluggy-1.5.0-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/lfj9h46jsidlg7mg4yy33rspmls6a046-python3.12-pytest-8.2.2-aarch64-unknown-linux-gnu/lib/python3.12/site-packages/_pytest/python.py", line 162, in pytest_pyfunc_call
    result = testfunction(**testargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/build/Mako-1.3.5/test/test_template.py", line 1756, in test_future_import
    assert result_lines(t.render(x=12, y=5)) == ["2.4"]
AssertionError: assert ['2.3999999999999999'] == ['2.4']

  At index 0 diff: '2.3999999999999999' != '2.4'

  Full diff:
    [
  -     '2.4',
  +     '2.3999999999999999',
    ]
=============================== warnings summary ===============================
test/ext/test_babelplugin.py: 32 warnings
  /nix/store/hv4r766mi1ldavss9dg5nagb80cgifs1-python3.12-babel-2.15.0/lib/python3.12/site-packages/babel/messages/extract.py:643: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
    if isinstance(body, ast.Str):

test/ext/test_babelplugin.py: 31 warnings
  /nix/store/hv4r766mi1ldavss9dg5nagb80cgifs1-python3.12-babel-2.15.0/lib/python3.12/site-packages/babel/messages/extract.py:644: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
    return body.s

test/ext/test_linguaplugin.py::MakoExtractTest::test_extract
  /nix/store/4svh14lbp62c25jc3073sgkddh8dr5i9-python3.12-lingua-4.15.0/lib/python3.12/site-packages/lingua/extractors/__init__.py:2: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    from pkg_resources import DistributionNotFound

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED test/test_template.py::FuturesTest::test_future_import - AssertionError: assert ['2.3999999999999999'] == ['2.4']
=========== 1 failed, 449 passed, 49 skipped, 64 warnings in 18.87s ============
/nix/store/b4jyim3n8vlq4nqcasfhq8kqs3y80wkc-stdenv-linux/setup: line 1641: pop_var_context: head of shell_variables not a function context

Discovered with Nix

Activity

  1. zzzeek commented on Jul 27, 2024

    @zzzeek
    Member

    I cant reproduce , note python 3.12 below

    ]$ pytest test/test_template.py::FuturesTest::test_future_import 
    ==================================================================================== test session starts =====================================================================================
    platform linux -- Python 3.12.4, pytest-8.1.0, pluggy-1.4.0 -- /home/classic/.venv3/bin/python
    cachedir: .pytest_cache
    rootdir: /home/classic/dev/mako
    configfile: setup.cfg
    plugins: xdist-3.4.0, anyio-4.1.0, random-0.2, repeat-0.9.3
    collected 1 item                                                                                                                                                                             
    
    test/test_template.py::FuturesTest::test_future_import PASSED                                                                                                                          [100%]
    
    ===================================================================================== 1 passed in 0.05s ======================================================================================
    [classic@framework mako:review/michael_bayer/update_pyproject]$ 
  2. RossComputerGuy commented on Jul 27, 2024

    @RossComputerGuy
    Author

    Interesting, are you on aarch64? I'm doing this on NixOS on an aarch64 system (Apple Silicon M1 Pro). I've tried running this test multiple times and it consistently. I also am using an LLVM built environment so I wonder if some sort of optimization could have caused this.

  3. zzzeek commented on Jul 27, 2024

    @zzzeek
    Member

    OK so this is some kind of CPU thing? im on x86_64. if this is doing a pure FP comparison then the test should be changed to use rounding or something, feel free to send a PR.

  4. RossComputerGuy commented on Jul 27, 2024

    @RossComputerGuy
    Author

    Possibly, I am not 100% sure. I'm going to try an x86_64 machine as well.

  5. alyssais commented on Feb 4, 2025

    @alyssais

    This happens to me on Apple Silicon also. Not in the default environment, and not in the LLVM one that @RossComputerGuy is using, but in a musl cross compliation environment. It does not happen in a musl native environment.

  6. alyssais commented on Feb 4, 2025

    @alyssais

    Confirmed it happens on a non-Apple Silicon aarch64 machine too.

  7. sqla-tester commented on Feb 4, 2025

    @sqla-tester
    Collaborator

    Mike Bayer has proposed a fix for this issue in the main branch:

    update future import test https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/5683

  8. alyssais commented on Feb 4, 2025

    @alyssais

    Proposed patch solves my problem.

  9. added a commit that references this issue on Feb 5, 2025
    188d543
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions