Convert not_implemented to use a warning subclass.
This commit is contained in:
parent
71cd314f56
commit
869e4ca6a6
9 changed files with 38 additions and 8 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from toga import NotImplementedWarning
|
||||
|
||||
from . import dialogs
|
||||
from .app import App, MainWindow
|
||||
from .command import Command
|
||||
|
|
@ -31,7 +33,7 @@ from .window import Window
|
|||
|
||||
|
||||
def not_implemented(feature):
|
||||
print(f"[Android] Not implemented: {feature}") # pragma: nocover
|
||||
NotImplementedWarning.warn("Android", feature) # pragma: nocover
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from toga import NotImplementedWarning
|
||||
|
||||
from . import dialogs
|
||||
from .app import App, DocumentApp, MainWindow
|
||||
from .command import Command
|
||||
|
|
@ -35,7 +37,7 @@ from .window import Window
|
|||
|
||||
|
||||
def not_implemented(feature):
|
||||
print(f"[Cocoa] Not implemented: {feature}") # pragma: nocover
|
||||
NotImplementedWarning.warn("Cocoa", feature) # pragma: nocover
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import warnings
|
||||
|
||||
from .app import App, DocumentApp, DocumentMainWindow, MainWindow
|
||||
|
||||
# Resources
|
||||
|
|
@ -37,7 +39,19 @@ from .widgets.tree import Tree
|
|||
from .widgets.webview import WebView
|
||||
from .window import Window
|
||||
|
||||
|
||||
class NotImplementedWarning(RuntimeWarning):
|
||||
# pytest.warns() requires that Warning() subclasses are constructed by passing a
|
||||
# single argument (the warning message). Use a factory method to avoid reproducing
|
||||
# the message format and the warn invocation.
|
||||
@classmethod
|
||||
def warn(self, platform, feature):
|
||||
"""Raise a warning that a feature isn't implemented on a platform."""
|
||||
warnings.warn(NotImplementedWarning(f"[{platform}] Not implemented: {feature}"))
|
||||
|
||||
|
||||
__all__ = [
|
||||
"NotImplementedWarning",
|
||||
# Applications
|
||||
"App",
|
||||
"DocumentApp",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from toga import NotImplementedWarning
|
||||
|
||||
from . import dialogs
|
||||
from .app import App, DocumentApp, MainWindow
|
||||
from .command import Command
|
||||
|
|
@ -36,7 +38,7 @@ from .window import Window
|
|||
|
||||
|
||||
def not_implemented(feature):
|
||||
raise NotImplementedError()
|
||||
NotImplementedWarning.warn("Dummy", feature) # pragma: nocover
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from toga import NotImplementedWarning
|
||||
|
||||
from . import dialogs
|
||||
from .app import App, DocumentApp, MainWindow
|
||||
from .command import Command
|
||||
|
|
@ -32,7 +34,7 @@ from .window import Window
|
|||
|
||||
|
||||
def not_implemented(feature):
|
||||
print(f"[GTK+] Not implemented: {feature}") # pragma: nocover
|
||||
NotImplementedWarning.warn("GTK", feature) # pragma: nocover
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from toga import NotImplementedWarning
|
||||
|
||||
from . import dialogs
|
||||
from .app import App, MainWindow
|
||||
from .colors import native_color
|
||||
|
|
@ -36,7 +38,7 @@ from .window import Window
|
|||
|
||||
|
||||
def not_implemented(feature):
|
||||
print(f"[iOS] Not implemented: {feature}") # pragma: nocover
|
||||
NotImplementedWarning.warn("iOS", feature) # pragma: nocover
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from toga import NotImplementedWarning
|
||||
|
||||
from . import dialogs
|
||||
from .app import App, DocumentApp, MainWindow
|
||||
|
||||
|
|
@ -41,7 +43,7 @@ from .window import Window
|
|||
|
||||
|
||||
def not_implemented(feature):
|
||||
print(f"[Textual] Not implemented: {feature}") # pragma: nocover
|
||||
NotImplementedWarning.warn("Textual", feature) # pragma: nocover
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from toga import NotImplementedWarning
|
||||
|
||||
from . import dialogs
|
||||
from .app import App, MainWindow # DocumentApp
|
||||
from .command import Command
|
||||
|
|
@ -39,7 +41,7 @@ from .widgets.textinput import TextInput
|
|||
|
||||
|
||||
def not_implemented(feature):
|
||||
print(f"[Web] Not implemented: {feature}") # pragma: nocover
|
||||
NotImplementedWarning.warn("Web", feature) # pragma: nocover
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from toga import NotImplementedWarning
|
||||
|
||||
from . import dialogs
|
||||
from .app import App, MainWindow
|
||||
from .command import Command
|
||||
|
|
@ -31,7 +33,7 @@ from .window import Window
|
|||
|
||||
|
||||
def not_implemented(feature):
|
||||
print(f"[Winforms] Not implemented: {feature}") # pragma: nocover
|
||||
NotImplementedWarning.warn("Winforms", feature) # pragma: nocover
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
|
|
|||
Loading…
Reference in a new issue