Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test for checking all default swear words #24

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import unittest

import better_profanity
from better_profanity import profanity, Profanity
import os


class ProfanityTest(unittest.TestCase):
Expand Down Expand Up @@ -118,6 +120,19 @@ def test_init_with_bad_type(self):
with self.assertRaises(TypeError):
Profanity(False)

def test_all_default_words(self):
"""Tests that every word in the default word list is censored"""
wordlist_path = os.path.join(
better_profanity.__file__, "../profanity_wordlist.txt"
)
wordlist_path = os.path.abspath(wordlist_path)
with open(wordlist_path) as f:
for word in f.readlines():
word = word.strip()
if word:
self.assertEqual(profanity.censor(word)[:4], "****")
self.assertTrue(profanity.contains_profanity(word))


class ProfanityUnicodeTestRussian(unittest.TestCase):
def setUp(self):
Expand Down