mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
use per_counter
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import asyncio
|
from time import perf_counter
|
||||||
from time import time
|
|
||||||
|
|
||||||
from textual.app import App, ComposeResult
|
from textual.app import App, ComposeResult
|
||||||
from textual.widgets import Static
|
from textual.widgets import Static
|
||||||
@@ -28,18 +27,18 @@ async def test_animate_height() -> None:
|
|||||||
static = app.query_one(Static)
|
static = app.query_one(Static)
|
||||||
assert static.size.height == 1
|
assert static.size.height == 1
|
||||||
static.styles.animate("height", 100, duration=0.5, easing="linear")
|
static.styles.animate("height", 100, duration=0.5, easing="linear")
|
||||||
start = time()
|
start = perf_counter()
|
||||||
|
|
||||||
# Wait for half the animation
|
# Wait for half the animation
|
||||||
await pilot.pause(0.25)
|
await pilot.pause(0.25)
|
||||||
# Check we reached the half way point
|
# Check we reached the half way point
|
||||||
assert static.styles.height.value >= 50
|
assert static.styles.height.value >= 50
|
||||||
elapsed = time() - start
|
elapsed = perf_counter() - start
|
||||||
# Check at least that much time has elapsed
|
# Check at least that much time has elapsed
|
||||||
assert 0.5 > elapsed > 0.25
|
assert 0.5 > elapsed > 0.25
|
||||||
# Wait for the animation to finished
|
# Wait for the animation to finished
|
||||||
await pilot.wait_for_animation()
|
await pilot.wait_for_animation()
|
||||||
elapsed = time() - start
|
elapsed = perf_counter() - start
|
||||||
# Check that the full time has elapsed
|
# Check that the full time has elapsed
|
||||||
assert elapsed > 0.5
|
assert elapsed > 0.5
|
||||||
# Check the height reached the maximum
|
# Check the height reached the maximum
|
||||||
|
|||||||
Reference in New Issue
Block a user