Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_util fails with Python 3.13 #3761

Open
mattiaverga opened this issue Jun 15, 2024 · 5 comments · May be fixed by #3762
Open

test_util fails with Python 3.13 #3761

mattiaverga opened this issue Jun 15, 2024 · 5 comments · May be fixed by #3762

Comments

@mattiaverga
Copy link

Two tests in test_util started to fail in Fedora Linux after the move to Python 3.13.0b2:

============================= test session starts ==============================
platform linux -- Python 3.13.0b2, pytest-7.4.3, pluggy-1.3.0
rootdir: /builddir/build/BUILD/python-pyramid-2.0.2-build/pyramid-2.0.2
configfile: setup.cfg
plugins: cov-4.0.0
collected 2635 items
tests/test_asset.py ...........                                          [  0%]
tests/test_authentication.py ........................................... [  2%]
........................................................................ [  4%]
................................................                         [  6%]
tests/test_authorization.py ........................                     [  7%]
tests/test_csrf.py ........................................              [  9%]
tests/test_decorator.py ....                                             [  9%]
tests/test_encode.py ...............                                     [  9%]
tests/test_events.py .......................................             [ 11%]
tests/test_exceptions.py ...........                                     [ 11%]
tests/test_httpexceptions.py ........................................... [ 13%]
................                                                         [ 13%]
tests/test_i18n.py ............................................          [ 15%]
tests/test_integration.py .............................................. [ 17%]
........................................................................ [ 20%]
......                                                                   [ 20%]
tests/test_location.py ..                                                [ 20%]
tests/test_paster.py ........                                            [ 20%]
tests/test_path.py ..................................................... [ 22%]
............................                                             [ 23%]
tests/test_predicates.py ............................................... [ 25%]
........................                                                 [ 26%]
tests/test_registry.py ....................................              [ 27%]
tests/test_renderers.py ................................................ [ 29%]
..............                                                           [ 30%]
tests/test_request.py .................................................. [ 32%]
.....                                                                    [ 32%]
tests/test_response.py ...............                                   [ 32%]
tests/test_router.py ................................................... [ 34%]
.........                                                                [ 35%]
tests/test_scripting.py .............                                    [ 35%]
tests/test_security.py ...............................................   [ 37%]
tests/test_session.py .................................................. [ 39%]
..........................................                               [ 40%]
tests/test_settings.py ...................                               [ 41%]
tests/test_static.py ................................................... [ 43%]
...                                                                      [ 43%]
tests/test_testing.py .................................................. [ 45%]
.............................                                            [ 46%]
tests/test_threadlocal.py ........                                       [ 46%]
tests/test_traversal.py ................................................ [ 48%]
.................................................                        [ 50%]
tests/test_tweens.py .....                                               [ 50%]
tests/test_url.py ...................................................... [ 52%]
.........................................................                [ 54%]
tests/test_urldispatch.py .............................................. [ 56%]
....                                                                     [ 56%]
tests/test_util.py ..............F...........F.......................... [ 58%]
........................................................................ [ 61%]
                                                                         [ 61%]
tests/test_view.py ..................................................... [ 63%]
..........................                                               [ 64%]
tests/test_viewderivers.py ............................................. [ 66%]
....................................................                     [ 68%]
tests/test_wsgi.py ...........                                           [ 68%]
tests/test_config/test_actions.py ...................................... [ 70%]
........                                                                 [ 70%]
tests/test_config/test_adapters.py .....................                 [ 71%]
tests/test_config/test_assets.py ....................................... [ 72%]
....................................................................     [ 75%]
tests/test_config/test_factories.py ..................                   [ 76%]
tests/test_config/test_i18n.py ..............                            [ 76%]
tests/test_config/test_init.py ......................................... [ 78%]
............................................................             [ 80%]
tests/test_config/test_predicates.py ................................... [ 81%]
....                                                                     [ 81%]
tests/test_config/test_rendering.py ...                                  [ 81%]
tests/test_config/test_routes.py ...............................         [ 83%]
tests/test_config/test_security.py ..............                        [ 83%]
tests/test_config/test_settings.py ........................              [ 84%]
tests/test_config/test_testing.py ............                           [ 85%]
tests/test_config/test_tweens.py .................................       [ 86%]
tests/test_config/test_views.py ........................................ [ 87%]
........................................................................ [ 90%]
........................................................................ [ 93%]
......................................................................   [ 95%]
tests/test_scripts/test_common.py ..                                     [ 96%]
tests/test_scripts/test_pdistreport.py ..                                [ 96%]
tests/test_scripts/test_prequest.py ...................                  [ 96%]
tests/test_scripts/test_proutes.py ..............................        [ 97%]
tests/test_scripts/test_pserve.py .........                              [ 98%]
tests/test_scripts/test_pshell.py .................                      [ 98%]
tests/test_scripts/test_ptweens.py .....                                 [ 99%]
tests/test_scripts/test_pviews.py .......................                [100%]
=================================== FAILURES ===================================
____________ Test_InstancePropertyHelper.test_property_without_name ____________
self = <tests.test_util.Test_InstancePropertyHelper testMethod=test_property_without_name>
    def test_property_without_name(self):
        def worker(obj):  # pragma: no cover
            pass
    
        foo = Dummy()
        helper = self._getTargetClass()
>       self.assertRaises(
            ValueError, helper.set_property, foo, property(worker)
        )
E       AssertionError: ValueError not raised by set_property
tests/test_util.py:74: AssertionError
____________ Test_InstancePropertyMixin.test_property_without_name _____________
self = <tests.test_util.Test_InstancePropertyMixin testMethod=test_property_without_name>
    def test_property_without_name(self):
        def worker(obj):  # pragma: no cover
            pass
    
        foo = self._makeOne()
>       self.assertRaises(ValueError, foo.set_property, property(worker))
E       AssertionError: ValueError not raised by set_property
tests/test_util.py:278: AssertionError

Full logs are available at https://koji.fedoraproject.org/koji/taskinfo?taskID=119046120

@mattiaverga
Copy link
Author

with Python 3.12:

>>> def worker(obj):
...     pass
...
>>> hasattr(property(worker), '__name__')
False

With Python 3.13:

>>> def worker(obj):
...     pass
...
>>> hasattr(property(worker), '__name__')
True
>>> property(worker).__name__
'worker'

@mattiaverga
Copy link
Author

See python/cpython#101860

Would changing

pyramid/src/pyramid/util.py

Lines 110 to 116 in ef0f686

if name is None:
if not hasattr(callable, '__name__'):
raise ValueError(
'missing __name__, must specify "name" for property'
)
name = callable.__name__
name = get_callable_name(name)

to
if not hasattr(callable, '__name__') or isinstance(callable, property):
a suitable fix?

@hroncok
Copy link

hroncok commented Jun 17, 2024

As I understand it, that would force the caller to manually pass a name for the property, while with Python 3.13+ it is no longer necessary. I would rather adjust the test and allow this.

@hroncok
Copy link

hroncok commented Jun 17, 2024

I am working on a pull request.

@hroncok
Copy link

hroncok commented Jun 17, 2024

#3762

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants