def test_will_download_file(self):
        test_url = 'http://www.google.com/images/logos/ps_logo2.png'

        tempdir = tempfile.mkdtemp() 

        download_url_to(test_url, tempdir)

        self.assertTrue(os.path.isfile(os.path.join(
            tempdir, 'ps_logo2.png')))
Exemplo n.º 2
0
def get_selenium(url=JAR_DOWNLOAD_URL):
    """
    If needed, will grab the Selenium 2 jar file from the Internet and save it
    locally.  It then updates the config file with the new location of the jar.
    """
    try:
        path = config.get('selenium', 'jar_filename')
        if os.path.isfile(path):
            # We've already fetched Selenium, and the config has been updated
            return
    except ConfigParser.Error:
        # Selenium has not been fetched and the config has not been updated
        pass

    path = download_url_to(url, tempfile.mkdtemp())

    try:
        config.add_section('selenium')
    except ConfigParser.DuplicateSectionError:
        # We already have the section, that's ok
        pass

    config.set('selenium', 'jar_filename', path)

    save_config(config)