<commit_before># -*- coding: utf-8 -*-

from __future__ import with_statement

import unittest
import warnings

from nose.tools import assert_equals, raises
from splinter.exceptions import DriverNotFoundError


class BrowserTest(unittest.TestCase):

    @raises(DriverNotFoundError)
    def test_should_raise_an_exception_when_browser_driver_is_not_found(self):
        from splinter.browser import Browser
        Browser('unknown-driver')


class BrowserDeprecationTest(unittest.TestCase):

    class Foo(object):
        pass

    def test_should_deprecate_with_the_given_message(self):
        from splinter.browser import deprecate
        with warnings.catch_warnings(record=True) as warnings_list:
            cls = deprecate(self.Foo, message="Foo was deprecated")
            cls()
            warning = warnings_list[0]
            assert type(warning.message) is DeprecationWarning
            assert_equals("Foo was deprecated", warning.message.args[0])

    def test_should_prepend_a_Deprecated_to_class(self):
        from splinter.browser import deprecate
        with warnings.catch_warnings(record=True):
            cls = deprecate(self.Foo, message="Foo was deprecated")
            assert_equals("DeprecatedFoo", cls.__name__)

    def test_webdriverfirefox_should_be_deprecated(self):
        with warnings.catch_warnings(record=True) as warnings_list:
            from splinter.browser import Browser
            browser = Browser('webdriver.firefox')
            browser.quit()
            warning_message = warnings_list[0].message.args[0]
            assert_equals("'webdriver.firefox' is deprecated, use just 'firefox'", warning_message)

    def test_webdriverchrome_should_be_deprecated(self):
        with warnings.catch_warnings(record=True) as warnings_list:
            from splinter.browser import Browser
            browser = Browser('webdriver.chrome')
            browser.quit()
            warning_message = warnings_list[0].message.args[0]
            assert_equals("'webdriver.chrome' is deprecated, use just 'chrome'", warning_message)<commit_msg>Fixing behavior of warnings tests on Python 2.7 (about issue #96)<commit_after># -*- coding: utf-8 -*-

from __future__ import with_statement

import unittest
import warnings

from nose.tools import assert_equals, raises
from splinter.exceptions import DriverNotFoundError


class BrowserTest(unittest.TestCase):

    @raises(DriverNotFoundError)
    def test_should_raise_an_exception_when_browser_driver_is_not_found(self):
        from splinter.browser import Browser
        Browser('unknown-driver')


class BrowserDeprecationTest(unittest.TestCase):

    class Foo(object):
        pass

    def test_should_deprecate_with_the_given_message(self):
        from splinter.browser import deprecate
        with warnings.catch_warnings(record=True) as warnings_list:
            warnings.simplefilter('default')
            cls = deprecate(self.Foo, message="Foo was deprecated")
            cls()
            warning = warnings_list[0]
            assert type(warning.message) is DeprecationWarning
            assert_equals("Foo was deprecated", warning.message.args[0])

    def test_should_prepend_a_Deprecated_to_class(self):
        from splinter.browser import deprecate
        with warnings.catch_warnings(record=True):
            warnings.simplefilter('default')
            cls = deprecate(self.Foo, message="Foo was deprecated")
            assert_equals("DeprecatedFoo", cls.__name__)

    def test_webdriverfirefox_should_be_deprecated(self):
        with warnings.catch_warnings(record=True) as warnings_list:
            warnings.simplefilter('default')
            from splinter.browser import Browser
            browser = Browser('webdriver.firefox')
            browser.quit()
            warning_message = warnings_list[0].message.args[0]
            assert_equals("'webdriver.firefox' is deprecated, use just 'firefox'", warning_message)

    def test_webdriverchrome_should_be_deprecated(self):
        with warnings.catch_warnings(record=True) as warnings_list:
            warnings.simplefilter('default')
            from splinter.browser import Browser
            browser = Browser('webdriver.chrome')
            browser.quit()
            warning_message = warnings_list[0].message.args[0]
            assert_equals("'webdriver.chrome' is deprecated, use just 'chrome'", warning_message)
{'fraction_non_alphanumeric': 0.08121597096188747, 'fraction_numerical': 0.004083484573502722, 'mean_word_length': 3.2889105058365757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '3789301', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1154, 'n_words': 253}