TestLanguageDetection.test_japanese_detection()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
nop 1
1
#!/usr/local/bin/python
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
# coding: utf-8
3
4
import unittest
5
6
from titlesearch.language.detection import matches_language
7
from titlesearch.language.language_settings import *
0 ignored issues
show
Coding Style introduced by
The usage of wildcard imports like titlesearch.language.language_settings should generally be avoided.
Loading history...
Unused Code introduced by
np was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
LanguageTemplate was imported with wildcard, but is not used.
Loading history...
8
9
10
class TestLanguageDetection(unittest.TestCase):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
11
    titles = [
12
        'Tate no Yuusha no Nariagari',
13
        'Tate no Yūsha no Nariagari',
14
        '盾の勇者の成り上がり',
15
        '방패 용사 성공담',
16
        'The Rising of the Shield Hero'
17
    ]
18
19
    EXPECTED_RESULTS_ENGLISH = [
20
        True,
21
        False,
22
        False,
23
        False,
24
        True
25
    ]
26
27
    EXPECTED_RESULTS_KOREAN = [
28
        False,
29
        False,
30
        False,
31
        True,
32
        False
33
    ]
34
35
    EXPECTED_RESULTS_JAPANESE = [
36
        False,
37
        False,
38
        True,
39
        False,
40
        False
41
    ]
42
43
    def test_korean_results(self):
44
        """Test the titles with the korean language configuration"""
45
        results = []
46
        for title in self.titles:
47
            results.append(matches_language(title, Korean))
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable Korean does not seem to be defined.
Loading history...
48
49
        self.assertEqual(self.EXPECTED_RESULTS_KOREAN, results)
50
51
    def test_japanese_detection(self):
52
        """Test the titles with the japanese language configuration"""
53
        results = []
54
        for title in self.titles:
55
            results.append(matches_language(title, Japanese))
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable Japanese does not seem to be defined.
Loading history...
56
57
        self.assertEqual(self.EXPECTED_RESULTS_JAPANESE, results)
58
59
    def test_english_detection(self):
60
        """Test the titles with the english language configuration"""
61
        results = []
62
        for title in self.titles:
63
            results.append(matches_language(title, English))
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable English does not seem to be defined.
Loading history...
64
65
        self.assertEqual(self.EXPECTED_RESULTS_ENGLISH, results)
66