-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use correct source_path in example #1433
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I also suggest adding a simple test to prevent this missing file link from happening again?
Something like this.
import os
import runpy
import unittest
#: Filename of the demo script
FILENAME = "Image_editor_demo.py"
#: Path of the demo script
DEMO_PATH = os.path.join(os.path.dirname(__file__), "..", FILENAME)
class TestImageEditorDemo(unittest.TestCase):
def test_image_path_exists(self):
search_path, = runpy.run_path(DEMO_PATH)["search_path"]
self.assertTrue(os.path.exists(search_path))
|
||
from traitsui.api \ | ||
import ImageEditor | ||
import View, VGroup, Item, ImageEditor | ||
|
||
from pyface.image_resource \ | ||
import ImageResource | ||
|
||
# Constants: | ||
|
||
# Necessary because of the dynamic way in which the demos are loaded: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I run the script from the command line, even just search_path = []
would work, but that's using some default magic (with inspection on where the code is running from etc.). I believe this is the magic:
https://github.com/enthought/traits/blob/a0d0a70331ec202eb33b6439570175c869fe353c/traits/trait_base.py#L256-L305
That would not work when this example is run from within the demo application. join(dirname(__file__))
remove the assumption and dependency on the magic: It is more explicit, which I think is a good thing to do anyway. Now the comment makes it look worse than this actually is.
What do you think about rewording the comment to something along the line of # The images folder is in the same folder as this file
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM. Thank you!
fixes #1432
This PR changes the search path the be the correct path to the directory that contains the image folder containing the images of interest.