mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
test fix
This commit is contained in:
@@ -3,10 +3,9 @@ Timer context manager, only used in debug.
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ._time import time
|
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
|
from time import perf_counter
|
||||||
|
|
||||||
from . import log
|
from . import log
|
||||||
|
|
||||||
@@ -14,8 +13,8 @@ from . import log
|
|||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def timer(subject: str = "time") -> Generator[None, None, None]:
|
def timer(subject: str = "time") -> Generator[None, None, None]:
|
||||||
"""print the elapsed time. (only used in debugging)"""
|
"""print the elapsed time. (only used in debugging)"""
|
||||||
start = time()
|
start = perf_counter()
|
||||||
yield
|
yield
|
||||||
elapsed = time() - start
|
elapsed = perf_counter() - start
|
||||||
elapsed_ms = elapsed * 1000
|
elapsed_ms = elapsed * 1000
|
||||||
log(f"{subject} elapsed {elapsed_ms:.2f}ms")
|
log(f"{subject} elapsed {elapsed_ms:.2f}ms")
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import platform
|
import platform
|
||||||
|
|
||||||
from time import monotonic, perf_counter
|
from time import monotonic, perf_counter
|
||||||
|
|
||||||
PLATFORM = platform.system()
|
PLATFORM = platform.system()
|
||||||
@@ -9,5 +10,3 @@ if WINDOWS:
|
|||||||
time = perf_counter
|
time = perf_counter
|
||||||
else:
|
else:
|
||||||
time = monotonic
|
time = monotonic
|
||||||
|
|
||||||
time = monotonic
|
|
||||||
|
|||||||
@@ -3,16 +3,15 @@ from __future__ import annotations
|
|||||||
import asyncio
|
import asyncio
|
||||||
import inspect
|
import inspect
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import pickle
|
import pickle
|
||||||
from asyncio import Queue, Task, QueueFull
|
from asyncio import Queue, QueueFull, Task
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from typing import Type, Any, NamedTuple
|
from time import time
|
||||||
|
from typing import Any, NamedTuple, Type
|
||||||
|
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.segment import Segment
|
from rich.segment import Segment
|
||||||
|
|
||||||
from .._time import time
|
|
||||||
from .._log import LogGroup, LogVerbosity
|
from .._log import LogGroup, LogVerbosity
|
||||||
|
|
||||||
|
|
||||||
@@ -22,12 +21,12 @@ class DevtoolsDependenciesMissingError(Exception):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
import msgpack
|
||||||
from aiohttp import (
|
from aiohttp import (
|
||||||
ClientResponseError,
|
|
||||||
ClientConnectorError,
|
ClientConnectorError,
|
||||||
|
ClientResponseError,
|
||||||
ClientWebSocketResponse,
|
ClientWebSocketResponse,
|
||||||
)
|
)
|
||||||
import msgpack
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# TODO: Add link to documentation on how to install devtools
|
# TODO: Add link to documentation on how to install devtools
|
||||||
raise DevtoolsDependenciesMissingError(
|
raise DevtoolsDependenciesMissingError(
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ import asyncio
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from . import events
|
from . import _clock, events
|
||||||
from ._time import time
|
|
||||||
from ._types import MessageTarget
|
from ._types import MessageTarget
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@@ -20,7 +19,7 @@ class Driver(ABC):
|
|||||||
self._target = target
|
self._target = target
|
||||||
self._debug = debug
|
self._debug = debug
|
||||||
self._loop = asyncio.get_running_loop()
|
self._loop = asyncio.get_running_loop()
|
||||||
self._mouse_down_time = time()
|
self._mouse_down_time = _clock.get_time_no_wait()
|
||||||
|
|
||||||
def send_event(self, event: events.Event) -> None:
|
def send_event(self, event: events.Event) -> None:
|
||||||
asyncio.run_coroutine_threadsafe(
|
asyncio.run_coroutine_threadsafe(
|
||||||
|
|||||||
@@ -14,16 +14,16 @@ from functools import partial
|
|||||||
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Iterable
|
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Iterable
|
||||||
from weakref import WeakSet
|
from weakref import WeakSet
|
||||||
|
|
||||||
from . import events, log, messages, Logger
|
from . import Logger, events, log, messages
|
||||||
from ._callback import invoke
|
from ._callback import invoke
|
||||||
from ._context import NoActiveAppError, active_app
|
from ._context import NoActiveAppError, active_app
|
||||||
from ._time import time
|
from ._time import time
|
||||||
from .errors import DuplicateKeyHandlers
|
|
||||||
from .timer import Timer, TimerCallback
|
|
||||||
from .case import camel_to_snake
|
from .case import camel_to_snake
|
||||||
|
from .errors import DuplicateKeyHandlers
|
||||||
from .events import Event
|
from .events import Event
|
||||||
from .message import Message
|
from .message import Message
|
||||||
from .reactive import Reactive
|
from .reactive import Reactive
|
||||||
|
from .timer import Timer, TimerCallback
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .app import App
|
from .app import App
|
||||||
|
|||||||
Reference in New Issue
Block a user