-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_app.py
More file actions
63 lines (43 loc) · 1.36 KB
/
test_app.py
File metadata and controls
63 lines (43 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from text import (
Token,
Sentence,
Text
)
import unittest
import numpy as np
class TestToken(unittest.TestCase):
@classmethod
def setUpClass(self):
np.random.seed(31)
def test_get_string(self):
token = Token("Hallo")
self.assertEqual(token.get_string(), 'Hallo')
def test_shuffle_letters(self):
word = "Allgäu"
token = Token(word)
token.shuffle()
word_shuffled = token.get_string()
self.assertEqual(len(word_shuffled), len(word))
self.assertNotEqual(word_shuffled, word)
class TestSentence(unittest.TestCase):
@classmethod
def setUpClass(self):
np.random.seed(31)
def setUp(self):
self.sentence = "This is awesome python code"
def test_get_string(self):
sentence = Sentence(self.sentence)
self.assertEqual(sentence.get_string(), self.sentence)
def test_shuffle(self):
sentence = Sentence(self.sentence)
sentence.shuffle()
self.assertNotEqual(sentence.get_string(), self.sentence)
class TestText(unittest.TestCase):
@classmethod
def setUpClass(self):
np.random.seed(31)
def setUp(self):
self.text = "This is awesome python code. It is free of bugs"
def test_get_string(self):
text = Text(self.text)
self.assertEqual(text.get_string(), self.text)