Skip to content

Instantly share code, notes, and snippets.

@janithl janithl/
Created Dec 18, 2016

What would you like to do?
import unittest
from getlang import getlang
class TestLang(unittest.TestCase):
"""Tests for ``."""
def test_is_english(self):
self.assertTrue(getlang('hello') == 'en')
self.assertTrue(getlang('<2323$(@*(*&^&@^#>e') == 'en')
self.assertTrue(getlang('a') == 'en')
def test_is_tamil(self):
self.assertTrue(getlang('வணக்கம்') == 'ta')
self.assertTrue(getlang('%^&%^&%வ^$%^#$#') == 'ta')
self.assertTrue(getlang('') == 'ta')
def test_is_sinhala(self):
self.assertTrue(getlang('ආයුබෝවන්') == 'si')
self.assertTrue(getlang('%^&%^&%කෝ^$%^#$#') == 'si')
self.assertTrue(getlang('') == 'si')
def test_mixed(self):
self.assertTrue(getlang('hey ආයුබෝවන්') == 'si') # mostly sinhala
self.assertTrue(getlang('english text with a single வணக்கம்') == 'en') # mostly english
self.assertTrue(getlang('எதைப் பரிந்துரைக்கிறீர்கள்?') == 'ta') #mostly tamil
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.