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)
    def test_will_write_configuration_after_download(self):
        test_url = 'http://www.google.com/images/logos/ps_logo2.png'

        # Give it an alternative url for testing
        get_selenium(url=test_url)

        from threefour import config
        jar_filename = config.get('selenium', 'jar_filename')

        self.assertTrue(os.path.isfile(jar_filename))
        self.assertIn('ps_logo2.png', jar_filename)