Convert not-implemented
to use warnings
#2398
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a set of changes that came out of the implementation of MapView in #2379.
Toga has provided a
not_implemented()
helper for a long time; however, it's been implemented as a simple print statement. This means it cannot be easily monitored or silences, and repeated calls to the method result in repeated messages in the console (which can be overwhelming).This converts
not_implemented()
to raise a NotImplementedWarning. The slightly oddwarn()
class method is needed becausepytest.warns()
requires warnings to accept a single argument (the warning message) if they're uncaught and reraised.To ensure this new feature is exercised,
WebView.on_webview_load
handler has been modified to raise a warning if the backend doesn't support the handler (as is the case with Android). MapView will have analogous handling foron_select
events on the map.To ensure the warnings are handled, this PR also promotes warnings to full errors in the core tests. This was already being done on the testbed, but the implementation has been modified in this PR to ignore NotImplementedWarnings. This revealed a number of warnings that the core test suite wasn't handling; tests have been updated to reflect this. Amongst these warnings were warnings on Python 3.12 about there being no current event loop; the app tests that instantiate
toga.App
have all been modified to reference theevent_loop
fixture to ensure an event loop exists.PR Checklist: