diff --git a/tests/snapshot_tests/snapshot_apps/hot_reloading_app.css b/tests/snapshot_tests/snapshot_apps/hot_reloading_app.css index e69de29bb..5e9ee82eb 100644 --- a/tests/snapshot_tests/snapshot_apps/hot_reloading_app.css +++ b/tests/snapshot_tests/snapshot_apps/hot_reloading_app.css @@ -0,0 +1 @@ +/* This file is purposefully empty. */ diff --git a/tests/snapshot_tests/snapshot_apps/hot_reloading_app.py b/tests/snapshot_tests/snapshot_apps/hot_reloading_app.py index fa7bc1f82..d7fc82f22 100644 --- a/tests/snapshot_tests/snapshot_apps/hot_reloading_app.py +++ b/tests/snapshot_tests/snapshot_apps/hot_reloading_app.py @@ -7,6 +7,9 @@ from textual.widgets import Label CSS_PATH = (Path(__file__) / "../hot_reloading_app.css").resolve() +# Write some CSS to the file before the app loads. +# Then, the test will clear all the CSS to see if the +# hot reloading applies the changes correctly. CSS_PATH.write_text( """ Container { diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index f7b58d8c4..5e0f05cd2 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -343,10 +343,12 @@ def test_scrollbar_thumb_height(snap_compare): def test_css_hot_reloading(snap_compare): + """Regression test for https://github.com/Textualize/textual/issues/2063.""" + async def run_before(pilot): css_file = pilot.app.CSS_PATH with open(css_file, "w") as f: - f.write("") # Clear all the CSS. + f.write("/* This file is purposefully empty. */\n") # Clear all the CSS. await pilot.app._on_css_change() assert snap_compare(