test-kivy-app/kivy_venv/lib/python3.11/site-packages/kivy/tests/test_garden.py

24 lines
738 B
Python
Raw Normal View History

2024-09-15 12:12:16 +00:00
import os
from tempfile import TemporaryDirectory
from unittest import mock
def test_garden_import_module():
with TemporaryDirectory() as tmpdir:
fake_garden_dir = os.path.join(tmpdir, "garden")
with mock.patch("kivy.garden.garden_system_dir", fake_garden_dir):
# Add a fake garden module to the temporary directory
dummy_flower_dir = os.path.join(
fake_garden_dir, "garden.dummyflower"
)
os.makedirs(dummy_flower_dir, exist_ok=True)
with open(os.path.join(dummy_flower_dir, "__init__.py"), "w") as f:
f.write("dummy_var = 1")
from kivy.garden.dummyflower import dummy_var
assert dummy_var == 1