<commit_before>import os
import subprocess
import unittest

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.conf import settings


def use_saucelabs():
    return os.environ.get('TRAVIS') or os.environ.get('USE_SAUCELABS')


@unittest.skipIf(
    os.environ.get('TEST_SUITE') == 'nonfunctional',
    "nonfunctional tests specified in TEST_SUITE environment variable")
class SeleniumTestCase(StaticLiveServerTestCase):
    @classmethod
    def use_xvfb(cls):
        if not os.environ.get('SHOW_BROWSER', False):
            return subprocess.call(
                "type xvfb-run", shell=True,
                stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0
        else:
            return False

    @classmethod
    def get_firefox_driver(cls):
        caps = DesiredCapabilities.FIREFOX
        fp = webdriver.FirefoxProfile()
        # https://github.com/SeleniumHQ/selenium/issues/2701#issuecomment-275895137
        fp.set_preference('browser.tabs.remote.autostart.2', False)
        caps["marionette"] = True
        return webdriver.Firefox(
            capabilities=caps,
            firefox_profile=fp,
            log_path="%s/logs/webdriver.log" % settings.INSTALL_ROOT)

    @classmethod
    def setUpClass(cls):
        if use_saucelabs():
            browser, version, platform = os.environ['BROWSER'].split(":")
            caps = {'browserName': browser}
            caps['platform'] = platform
            caps['version'] = version
            # Disable slow script warning in IE
            caps['prerun'] = {
                'executable': ('https://raw.githubusercontent.com/'
                               'ebmdatalab/openprescribing/'
                               'master/scripts/setup_ie_8.bat'),
                'background': 'false'
            }
            username = os.environ["SAUCE_USERNAME"]
            access_key = os.environ["SAUCE_ACCESS_KEY"]
            if os.environ.get('TRAVIS'):
                caps["tunnel-identifier"] = os.environ.get(
                    "TRAVIS_JOB_NUMBER", 'n/a')<commit_msg>Fix screen resolution in tests<commit_after>import os
import subprocess
import unittest

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.conf import settings


def use_saucelabs():
    return os.environ.get('TRAVIS') or os.environ.get('USE_SAUCELABS')


@unittest.skipIf(
    os.environ.get('TEST_SUITE') == 'nonfunctional',
    "nonfunctional tests specified in TEST_SUITE environment variable")
class SeleniumTestCase(StaticLiveServerTestCase):
    @classmethod
    def use_xvfb(cls):
        if not os.environ.get('SHOW_BROWSER', False):
            return subprocess.call(
                "type xvfb-run", shell=True,
                stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0
        else:
            return False

    @classmethod
    def get_firefox_driver(cls):
        caps = DesiredCapabilities.FIREFOX
        fp = webdriver.FirefoxProfile()
        # https://github.com/SeleniumHQ/selenium/issues/2701#issuecomment-275895137
        fp.set_preference('browser.tabs.remote.autostart.2', False)
        caps["marionette"] = True
        return webdriver.Firefox(
            capabilities=caps,
            firefox_profile=fp,
            log_path="%s/logs/webdriver.log" % settings.INSTALL_ROOT)

    @classmethod
    def setUpClass(cls):
        if use_saucelabs():
            browser, version, platform = os.environ['BROWSER'].split(":")
            caps = {'browserName': browser}
            caps['platform'] = platform
            caps['version'] = version
            caps['screenResolution'] = '1600x1200'
            # Disable slow script warning in IE
            caps['prerun'] = {
                'executable': ('https://raw.githubusercontent.com/'
                               'ebmdatalab/openprescribing/'
                               'master/scripts/setup_ie_8.bat'),
                'background': 'false'
            }
            username = os.environ["SAUCE_USERNAME"]
            access_key = os.environ["SAUCE_ACCESS_KEY"]
            if os.environ.get('TRAVIS'):
                caps["tunnel-identifier"] = os.environ.get(
                    "TRAVIS_JOB_NUMBER", 'n/a')
{'fraction_non_alphanumeric': 0.10102040816326531, 'fraction_numerical': 0.00816326530612245, 'mean_word_length': 2.5617732558139537, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2366818', 'n_tokens_mistral': 1453, 'n_tokens_neox': 1380, 'n_words': 271}