<commit_before>#!/usr/bin/python

# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""PyAuto: Python Interface to Chromium's Automation Proxy.

PyAuto uses swig to expose Automation Proxy interfaces to Python.
For complete documentation on the functionality available,
run pydoc on this file.

Ref: http://dev.chromium.org/developers/pyauto
"""

import os
import sys
import unittest


def _LocateBinDirs():
  script_dir = os.path.dirname(__file__)
  chrome_src = os.path.join(script_dir, os.pardir, os.pardir, os.pardir)

  bin_dirs = {
      'linux2': [ os.path.join(chrome_src, 'out', 'Debug'),
                  os.path.join(chrome_src, 'sconsbuild', 'Debug'),
                  os.path.join(chrome_src, 'out', 'Release'),
                  os.path.join(chrome_src, 'sconsbuild', 'Release')],
      'darwin': [ os.path.join(chrome_src, 'xcodebuild', 'Debug'),
                  os.path.join(chrome_src, 'xcodebuild', 'Release')],
      'win32':  [ os.path.join(chrome_src, 'chrome', 'Debug'),
                  os.path.join(chrome_src, 'chrome', 'Release')],
      'cygwin': [ os.path.join(chrome_src, 'chrome', 'Debug'),
                  os.path.join(chrome_src, 'chrome', 'Release')],
  }
  sys.path += bin_dirs.get(sys.platform, [])

_LocateBinDirs()

try:
  from pyautolib import *
except ImportError:
  print >>sys.stderr, "Could not locate built libraries. Did you build?"
  raise


class PyUITest(PyUITestSuite, unittest.TestCase):
  """Base class for UI Test Cases in Python.

  A browser is created before executing each test, and is destroyed after
  each test irrespective of whether the test passed or failed.

  You should derive from this class and create methods with 'test' prefix,
  and use methods inherited from PyUITestSuite (the C++ side).

  Example:

    class MyTest(PyUITest):

      def testNavigation(self):
        self.NavigateToURL("http://www.google.com")
        self.assertTrue("Google" == self.GetActiveTabTitle())
  """

  def __init__(self, methodName='runTest'):
    PyUITestSuite.__init__(self, sys.argv)
    unittest.TestCase.__init__(self, methodName)

  def __del__(self):
    PyUITestSuite.__del__(self)

  def run(self, result=None):
    """The main run method.

    We override this method to make calls to the setup steps in PyUITestSuite.
    """
    self.SetUp()     # Open a browser window
    unittest.TestCase.run(self, result)
    self.TearDown()  # Destroy the browser window

  def GetState(self):
    """Get a state dictionary.

    The state dictionary contains properties of windows and tabs. Note that
    it's a snapshot so you need to fetch a new state everytime you expect a
    change.
    """
    out = {}
    out['user_data_dir'] = self.user_data_dir().value()
    out['browser_running'] = self.IsBrowserRunning()
    return out
<commit_msg>Revert a false commit (r39622)<commit_after>#!/usr/bin/python

# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""PyAuto: Python Interface to Chromium's Automation Proxy.

PyAuto uses swig to expose Automation Proxy interfaces to Python.
For complete documentation on the functionality available,
run pydoc on this file.

Ref: http://dev.chromium.org/developers/pyauto
"""

import os
import sys
import unittest


def _LocateBinDirs():
  script_dir = os.path.dirname(__file__)
  chrome_src = os.path.join(script_dir, os.pardir, os.pardir, os.pardir)

  bin_dirs = {
      'linux2': [ os.path.join(chrome_src, 'out', 'Debug'),
                  os.path.join(chrome_src, 'sconsbuild', 'Debug'),
                  os.path.join(chrome_src, 'out', 'Release'),
                  os.path.join(chrome_src, 'sconsbuild', 'Release')],
      'darwin': [ os.path.join(chrome_src, 'xcodebuild', 'Debug'),
                  os.path.join(chrome_src, 'xcodebuild', 'Release')],
      'win32':  [ os.path.join(chrome_src, 'chrome', 'Debug'),
                  os.path.join(chrome_src, 'chrome', 'Release')],
      'cygwin': [ os.path.join(chrome_src, 'chrome', 'Debug'),
                  os.path.join(chrome_src, 'chrome', 'Release')],
  }
  sys.path += bin_dirs.get(sys.platform, [])

_LocateBinDirs()

try:
  from pyautolib import *
except ImportError:
  print >>sys.stderr, "Could not locate built libraries. Did you build?"
  raise


class PyUITest(PyUITestSuite, unittest.TestCase):
  """Base class for UI Test Cases in Python.

  A browser is created before executing each test, and is destroyed after
  each test irrespective of whether the test passed or failed.

  You should derive from this class and create methods with 'test' prefix,
  and use methods inherited from PyUITestSuite (the C++ side).

  Example:

    class MyTest(PyUITest):

      def testNavigation(self):
        self.NavigateToURL("http://www.google.com")
        self.assertTrue("Google" == self.GetActiveTabTitle())
  """

  def __init__(self, methodName='runTest'):
    PyUITestSuite.__init__(self, sys.argv)
    unittest.TestCase.__init__(self, methodName)

  def __del__(self):
    PyUITestSuite.__del__(self)

  def run(self, result=None):
    """The main run method.

    We override this method to make calls to the setup steps in PyUITestSuite.
    """
    self.SetUp()     # Open a browser window
    unittest.TestCase.run(self, result)
    self.TearDown()  # Destroy the browser window

{'fraction_non_alphanumeric': 0.11934604904632153, 'fraction_numerical': 0.0034514078110808354, 'mean_word_length': 3.36984126984127, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6516184', 'n_tokens_mistral': 1779, 'n_tokens_neox': 1676, 'n_words': 512}