Skip to content

Test failures with Python 3.14.0b1: implicit event loop creation has been removed #265

@befeleme

Description

@befeleme

I try to build PyHamcrest with Python 3.14.0b1 for Fedora Linux, but the tests fail: implicit event loop creation has been removed: https://docs.python.org/dev/whatsnew/3.14.html#id7

The traceback:

_ FutureExceptionTest.testDoesNotMatchExceptionIfRegularExpressionDoesNotMatch _

self = <hamcrest_unit_test.core.future_test.FutureExceptionTest testMethod=testDoesNotMatchExceptionIfRegularExpressionDoesNotMatch>

    def testDoesNotMatchExceptionIfRegularExpressionDoesNotMatch(self):
        async def test():
            self.assert_does_not_match(
                "Bad regex",
                future_raising(AssertionError, "Phrase not found"),
                await resolved(raise_exception()),
            )
            self.assert_mismatch_description(
                '''Correct assertion type raised, but the expected pattern ("Phrase not found") not found. Exception message was: "(){}"''',
                future_raising(AssertionError, "Phrase not found"),
                await resolved(raise_exception()),
            )
    
>       asyncio.get_event_loop().run_until_complete(test())

tests/hamcrest_unit_test/core/future_test.py:124: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7fcd16ee82f0>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:718: RuntimeError
___________ FutureExceptionTest.testDoesNotMatchIfActualIsNotAFuture ___________

self = <hamcrest_unit_test.core.future_test.FutureExceptionTest testMethod=testDoesNotMatchIfActualIsNotAFuture>

    def testDoesNotMatchIfActualIsNotAFuture(self):
        async def test():
            self.assert_does_not_match("Not a future", future_raising(TypeError), 23)
    
>       asyncio.get_event_loop().run_until_complete(test())

tests/hamcrest_unit_test/core/future_test.py:50: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7fcd16ee82f0>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:718: RuntimeError
_____ FutureExceptionTest.testDoesNotMatchIfAdditionalMatchersDoesNotMatch _____

self = <hamcrest_unit_test.core.future_test.FutureExceptionTest testMethod=testDoesNotMatchIfAdditionalMatchersDoesNotMatch>

    def testDoesNotMatchIfAdditionalMatchersDoesNotMatch(self):
        async def test():
            self.assert_does_not_match(
                "Bad properties",
                future_raising(AssertionError, matching=has_properties(prop="prip")),
                await resolved(raise_exception_with_properties(prip="prop")),
            )
            self.assert_mismatch_description(
                '''Correct assertion type raised, but an object with a property 'prop' matching 'prip' not found. Exception message was: "boom"''',
                future_raising(AssertionError, matching=has_properties(prop="prip")),
                await resolved(raise_exception_with_properties(prip="prop")),
            )
    
>       asyncio.get_event_loop().run_until_complete(test())

tests/hamcrest_unit_test/core/future_test.py:165: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7fcd16ee82f0>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:718: RuntimeError
_______ FutureExceptionTest.testDoesNotMatchIfFutureDoesNotHaveException _______

self = <hamcrest_unit_test.core.future_test.FutureExceptionTest testMethod=testDoesNotMatchIfFutureDoesNotHaveException>

    def testDoesNotMatchIfFutureDoesNotHaveException(self):
        async def test():
            self.assert_does_not_match(
                "No exception", future_raising(ValueError), await resolved(no_exception())
            )
    
>       asyncio.get_event_loop().run_until_complete(test())

tests/hamcrest_unit_test/core/future_test.py:109: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7fcd16ee82f0>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:718: RuntimeError
___ FutureExceptionTest.testDoesNotMatchIfFutureHasTheWrongExceptionTypePy37 ___

self = <hamcrest_unit_test.core.future_test.FutureExceptionTest testMethod=testDoesNotMatchIfFutureHasTheWrongExceptionTypePy37>

    @pytest.mark.skipif(sys.version_info < (3, 7), reason="Message differs between Python versions")
    def testDoesNotMatchIfFutureHasTheWrongExceptionTypePy37(self):
        async def test():
            self.assert_does_not_match(
                "Wrong exception", future_raising(IOError), await resolved(raise_exception())
            )
            expected_message = (
                "AssertionError('(){}') of type <class 'AssertionError'> was raised instead"
            )
            self.assert_mismatch_description(
                expected_message, future_raising(TypeError), await resolved(raise_exception())
            )
    
>       asyncio.get_event_loop().run_until_complete(test())

tests/hamcrest_unit_test/core/future_test.py:91: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7fcd16ee82f0>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:718: RuntimeError
___________ FutureExceptionTest.testDoesNotMatchIfFutureIsCancelled ____________

self = <hamcrest_unit_test.core.future_test.FutureExceptionTest testMethod=testDoesNotMatchIfFutureIsCancelled>

    def testDoesNotMatchIfFutureIsCancelled(self):
>       future = asyncio.Future()

tests/hamcrest_unit_test/core/future_test.py:57: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7fcd16ee82f0>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:718: RuntimeError
____________ FutureExceptionTest.testDoesNotMatchIfFutureIsNotDone _____________

self = <hamcrest_unit_test.core.future_test.FutureExceptionTest testMethod=testDoesNotMatchIfFutureIsNotDone>

    def testDoesNotMatchIfFutureIsNotDone(self):
>       future = asyncio.Future()

tests/hamcrest_unit_test/core/future_test.py:53: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7fcd16ee82f0>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:718: RuntimeError
______ FutureExceptionTest.testDoesNotMatchIfNeitherPatternOrMatcherMatch ______

self = <hamcrest_unit_test.core.future_test.FutureExceptionTest testMethod=testDoesNotMatchIfNeitherPatternOrMatcherMatch>

    def testDoesNotMatchIfNeitherPatternOrMatcherMatch(self):
        async def test():
            self.assert_does_not_match(
                "Bad pattern and properties",
                future_raising(
                    AssertionError, pattern="asdf", matching=has_properties(prop="prip")
                ),
                await resolved(raise_exception_with_properties(prip="prop")),
            )
            self.assert_mismatch_description(
                '''Correct assertion type raised, but the expected pattern ("asdf") and an object with a property 'prop' matching 'prip' not found. Exception message was: "boom"''',
                future_raising(
                    AssertionError, pattern="asdf", matching=has_properties(prop="prip")
                ),
                await resolved(raise_exception_with_properties(prip="prop")),
            )
    
>       asyncio.get_event_loop().run_until_complete(test())

tests/hamcrest_unit_test/core/future_test.py:184: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7fcd16ee82f0>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:718: RuntimeError
______ FutureExceptionTest.testMachesIfExceptionMatchesAdditionalMatchers ______

self = <hamcrest_unit_test.core.future_test.FutureExceptionTest testMethod=testMachesIfExceptionMatchesAdditionalMatchers>

    def testMachesIfExceptionMatchesAdditionalMatchers(self):
        async def test():
            self.assert_matches(
                "Properties",
                future_raising(AssertionError, matching=has_properties(prip="prop")),
                await resolved(raise_exception_with_properties(prip="prop")),
            )
    
>       asyncio.get_event_loop().run_until_complete(test())

tests/hamcrest_unit_test/core/future_test.py:150: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7fcd16ee82f0>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:718: RuntimeError
__ FutureExceptionTest.testMatchesIfFutureHasASubclassOfTheExpectedException ___

self = <hamcrest_unit_test.core.future_test.FutureExceptionTest testMethod=testMatchesIfFutureHasASubclassOfTheExpectedException>

    def testMatchesIfFutureHasASubclassOfTheExpectedException(self):
        async def test():
            self.assert_matches(
                "Subclassed Exception",
                future_raising(Exception),
                await resolved(raise_exception()),
            )
    
>       asyncio.get_event_loop().run_until_complete(test())

tests/hamcrest_unit_test/core/future_test.py:101: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7fcd16ee82f0>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:718: RuntimeError
_____ FutureExceptionTest.testMatchesIfFutureHasTheExactExceptionExpected ______

self = <hamcrest_unit_test.core.future_test.FutureExceptionTest testMethod=testMatchesIfFutureHasTheExactExceptionExpected>

    def testMatchesIfFutureHasTheExactExceptionExpected(self):
        async def test():
            self.assert_matches(
                "Right exception",
                future_raising(AssertionError),
                await resolved(raise_exception()),
            )
    
>       asyncio.get_event_loop().run_until_complete(test())

tests/hamcrest_unit_test/core/future_test.py:44: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7fcd16ee82f0>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:718: RuntimeError
____ FutureExceptionTest.testMatchesRegularExpressionToStringifiedException ____

self = <hamcrest_unit_test.core.future_test.FutureExceptionTest testMethod=testMatchesRegularExpressionToStringifiedException>

    def testMatchesRegularExpressionToStringifiedException(self):
        async def test():
            self.assert_matches(
                "Regex",
                future_raising(AssertionError, "(3, 1, 4)"),
                await resolved(raise_exception(3, 1, 4)),
            )
    
            self.assert_matches(
                "Regex",
                future_raising(AssertionError, r"([\d, ]+)"),
                await resolved(raise_exception(3, 1, 4)),
            )
    
>       asyncio.get_event_loop().run_until_complete(test())

tests/hamcrest_unit_test/core/future_test.py:140: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7fcd16ee82f0>

    def get_event_loop(self):
        """Get the event loop for the current context.
    
        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib64/python3.14/asyncio/events.py:718: RuntimeError

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions