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

Convert not-implemented to use warnings #2398

Merged
merged 9 commits into from
Feb 19, 2024

Conversation

freakboy3742
Copy link
Member

@freakboy3742 freakboy3742 commented Feb 15, 2024

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 odd warn() class method is needed because pytest.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 for on_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 the event_loop fixture to ensure an event loop exists.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@mhsmith mhsmith merged commit ca25b32 into beeware:main Feb 19, 2024
35 checks passed
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 this pull request may close these issues.

None yet

2 participants