<commit_before>from mock import Mock
try:
    from urllib import urlencode
except ImportError:  # py3
    from urllib.parse import urlencode

from tornado.testing import AsyncHTTPTestCase
from qiita_pet.webserver import Application
from qiita_pet.handlers.base_handlers import BaseHandler
from qiita_db.environment_manager import clean_test_environment
from qiita_db.user import User


class TestHandlerBase(AsyncHTTPTestCase):
    database = False
    app = Application()

    def get_app(self):
        BaseHandler.get_current_user = Mock(return_value=User("<EMAIL>"))
        self.app.settings['debug'] = False
        return self.app

    def tearDown(self):
        if self.database:
            clean_test_environment()
        super(TestHandlerBase, self).tearDown()

    # helpers from http://www.peterbe.com/plog/tricks-asynchttpclient-tornado
    def get(self, url, data=None, headers=None, doseq=True):
        if data is not None:
            if isinstance(data, dict):
                data = urlencode(data, doseq=doseq)
            if '?' in url:<commit_msg>Changing the tornado test base to reset also on teardownclass<commit_after>from mock import Mock
try:
    from urllib import urlencode
except ImportError:  # py3
    from urllib.parse import urlencode

from tornado.testing import AsyncHTTPTestCase
from qiita_pet.webserver import Application
from qiita_pet.handlers.base_handlers import BaseHandler
from qiita_db.environment_manager import clean_test_environment
from qiita_db.user import User


class TestHandlerBase(AsyncHTTPTestCase):
    database = False
    app = Application()

    def get_app(self):
        BaseHandler.get_current_user = Mock(return_value=User("<EMAIL>"))
        self.app.settings['debug'] = False
        return self.app

    @classmethod
    def tearDownClass(cls):
        clean_test_environment()

    # helpers from http://www.peterbe.com/plog/tricks-asynchttpclient-tornado
    def get(self, url, data=None, headers=None, doseq=True):
        if data is not None:
            if isinstance(data, dict):
                data = urlencode(data, doseq=doseq)
            if '?' in url:
{'fraction_non_alphanumeric': 0.08009367681498829, 'fraction_numerical': 0.000936768149882904, 'mean_word_length': 3.422360248447205, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1669373', 'n_tokens_mistral': 642, 'n_tokens_neox': 626, 'n_words': 165}