Project

General

Profile

Revision 550:88e86cfe610f

Added by Daniel Havlik almost 8 years ago

re #12074 repair default setting for screenshot directory

View differences:

src/gocept/selenium/screenshot.py
176 176

  
177 177
def _screenshot_path(screenshot_directory):
178 178
    if screenshot_directory == '.':
179
        return os.path.dirname(inspect.getmodule(
180
            inspect.currentframe().f_back).__file__)
179
        screenshot_directory = \
180
            inspect.currentframe().f_back.f_back.f_back.f_globals['__name__']
181 181
    return pkg_resources.resource_filename(
182 182
            screenshot_directory, '')
183 183

  
src/gocept/selenium/tests/test_wd_selenese.py
139 139
        with self.assertRaises(ScreenshotMismatchError):
140 140
            self.selenium.assertScreenshot(
141 141
                    'screenshot_blocks', 'css=#block-2')
142

  
143

  
144
class ScreenshotDirectorySettingTest(HTMLTestCase):
145

  
146
    layer = STATIC_WD_LAYER
147

  
148
    def test_default_setting_when_not_set(self):
149
        #the default is the directory where the current test is
150
        img = pkg_resources.resource_filename(self.__module__, 'foo.png')
151
        self.selenium.capture_screenshot = True
152
        self.selenium.open('screenshot.html')
153
        with self.assertRaisesRegexp(ValueError, img):
154
            self.selenium.assertScreenshot('foo', 'css=#block-1')
155
        self.assertTrue(os.path.isfile(img))
156
        os.unlink(img)
157

  
158
    def test_screenshot_directory_setting_resolves_dotted_name(self):
159
        directory = 'gocept.selenium.tests.screenshot_directory'
160
        self.selenium.screenshot_directory = directory
161
        img = pkg_resources.resource_filename(directory, 'foo.png')
162
        self.selenium.capture_screenshot = True
163
        self.selenium.open('screenshot.html')
164
        with self.assertRaisesRegexp(ValueError, img):
165
            self.selenium.assertScreenshot('foo', 'css=#block-1')
166
        self.assertTrue(os.path.isfile(img))
167
        os.unlink(img)

Also available in: Unified diff