test failure as of Python 3.6.2

Issue #4034 resolved
Mike Bayer repo owner created an issue

released just on July 17:


SessionStateTest.test_with_no_autoflush_after_exception _________________________________________
Traceback (most recent call last):
  File "/home/classic/dev/sqlalchemy/test/orm/test_session.py", line 324, in test_with_no_autoflush_after_exception
    lambda obj: 1 / 0
  File "/home/classic/dev/sqlalchemy/test/../lib/sqlalchemy/testing/assertions.py", line 279, in assert_raises
    assert success, "Callable did not raise an exception"
AssertionError: Callable did not raise an exception
============================================= 1 failed, 77 passed, 4 skipped in 1.92 seconds ==============================================

clearly, 1/0 raises ZeroDivisionError by itself, someting is up with the fixtures or pytest or something. does not appear on 3.6.0.

Comments (5)

  1. Mike Bayer reporter

    OK the issue is the context manager simulator isn't following the spec per __exit__() correctly, this is the fix:

    diff --git a/lib/sqlalchemy/testing/util.py b/lib/sqlalchemy/testing/util.py
    index a37637a..fe696bc 100644
    --- a/lib/sqlalchemy/testing/util.py
    +++ b/lib/sqlalchemy/testing/util.py
    @@ -161,7 +161,7 @@ def run_as_contextmanager(ctx, fn, *arg, **kw):
         except:
             exc_info = sys.exc_info()
             raise_ = ctx.__exit__(*exc_info)
    -        if raise_ is None:
    +        if not raise_:
                 raise
             else:
                 return raise_
    

    probably stick to that for now, however we should probably use "with:" since we are long past Python versions that don't support it.

  2. Mike Bayer reporter

    Ensure we check for boolean condition when we inspect exit()

    Fixed issue in testing fixtures which was incompatible with a change made as of Python 3.6.2 involving context managers.

    Change-Id: I0f12aa6cc15cba89153f7e4888ac347e7ce599c7 Fixes: #4034

    → <<cset 7d4005156b5a>>

  3. Log in to comment