File: test_mount.py

package info (click to toggle)
textual 2.1.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,080 kB
  • sloc: python: 85,423; lisp: 1,669; makefile: 101
file content (27 lines) | stat: -rw-r--r-- 653 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Regression test for https://github.com/Textualize/textual/issues/2914

Make sure that calls to render only happen after a widget being mounted.
"""

import asyncio

from textual.app import App
from textual.widget import Widget


class W(Widget):
    def render(self):
        return self.renderable

    async def on_mount(self):
        await asyncio.sleep(0.1)
        self.renderable = "1234"


async def test_render_only_after_mount():
    """Regression test for https://github.com/Textualize/textual/issues/2914"""
    app = App()
    async with app.run_test() as pilot:
        app.mount(W())
        app.mount(W())
        await pilot.pause()