-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework custom
garden
importer to avoid usage of imp
module (remov…
…ed in Python `3.12`) (#8301) * UPDATE * Rework custom garden importer to avoid usage of imp module (removed in 3.12) * Apply black formatting * Fix flake8 error --------- Co-authored-by: Mirko Galimberti <me@mirkogalimberti.com>
- Loading branch information
1 parent
effc770
commit 64d295c
Showing
2 changed files
with
37 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
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 |