<commit_before># coding=utf-8
"""
"""
from __future__ import absolute_import

import datetime
import unittest
import mock
import pytz

from abilian.testing import BaseTestCase
from wtforms.form import Form

from . import fields, filters


def user_tz():
  # This one is GMT+8 and has no DST (tests should pass any time in year)
  return 'Asia/Hong_Kong'

USER_TZ = pytz.timezone(user_tz())


class FiltersTestCase(unittest.TestCase):

  def test_strip(self):
    assert filters.strip(None) == ''
    assert filters.strip(4) == 4
    assert filters.strip(' a string ') == 'a string'
    assert filters.strip(u' voilà ') == u'voilà'

  def test_uppercase(self):
    assert filters.uppercase(None) is None
    assert filters.uppercase(4) == 4
    assert filters.uppercase(' a string ') == ' A STRING '
    assert filters.uppercase(u' Voilà ') == u' VOILÀ '

  def test_lowercase(self):
    assert filters.lowercase(None) is None
    assert filters.lowercase(4) == 4
    assert filters.lowercase(' A STRING ') == ' a string '
    assert filters.lowercase(u' VOILÀ ') == u' voilà '

<commit_msg>web/forms/tests.py: filters test simplified for pytest<commit_after># coding=utf-8
"""
"""
from __future__ import absolute_import

import datetime
import mock
import pytz

from abilian.testing import BaseTestCase
from wtforms.form import Form

from . import fields, filters


def user_tz():
  # This one is GMT+8 and has no DST (tests should pass any time in year)
  return 'Asia/Hong_Kong'

USER_TZ = pytz.timezone(user_tz())


# test filters
def test_strip():
  assert filters.strip(None) == ''
  assert filters.strip(4) == 4
  assert filters.strip(' a string ') == 'a string'
  assert filters.strip(u' voilà ') == u'voilà'


def test_uppercase():
  assert filters.uppercase(None) is None
  assert filters.uppercase(4) == 4
  assert filters.uppercase(' a string ') == ' A STRING '
  assert filters.uppercase(u' Voilà ') == u' VOILÀ '


def test_lowercase():
  assert filters.lowercase(None) is None
  assert filters.lowercase(4) == 4
  assert filters.lowercase(' A STRING ') == ' a string '
  assert filters.lowercase(u' VOILÀ ') == u' voilà '





{'fraction_non_alphanumeric': 0.1191588785046729, 'fraction_numerical': 0.007476635514018692, 'mean_word_length': 4.014051522248243, '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': '2852914', 'n_tokens_mistral': 733, 'n_tokens_neox': 703, 'n_words': 215}