Exemplo n.º 1
0
 def setup_method(self):
     self.d = StenoDictionary()
     self.dc = StenoDictionaryCollection([self.d])
     self.s = _State()
     self.o = self.CaptureOutput()
     self.tlor = Translator()
     self.tlor.set_dictionary(self.dc)
     self.tlor.add_listener(self.o)
     self.tlor.set_state(self.s)
Exemplo n.º 2
0
 def reset(self, full=False, output=True):
     self._log.debug('reset steno state (full=%s)' % full)
     state = _State()
     state.tail = self._translator.get_state().last()
     if full or state.tail is None:
         state.tail = Translation([Stroke('*')], None)
         state.tail.formatting = [_Action(attach=True)]
     self._translator.set_state(state)
     if output:
         self._output.reset()
Exemplo n.º 3
0
 def test_last_tail1(self):
     s = _State()
     s.translations = [self.a]
     s.tail = self.b
     self.assertEqual(s.last(), self.a)
Exemplo n.º 4
0
 def test_last_list0(self):
     s = _State()
     self.assertIsNone(s.last())    
Exemplo n.º 5
0
 def test_restrict_size_multiple_translations(self):
     s = _State()
     s.translations = [self.a, self.b, self.c]
     s.restrict_size(5)
     assert s.translations == [self.b, self.c]
     assert s.tail == self.a
Exemplo n.º 6
0
 def test_restrict_size_zero_on_one_stroke(self):
     s = _State()
     s.translations = [self.a]
     s.restrict_size(0)
     assert s.translations == [self.a]
     assert s.tail is None
Exemplo n.º 7
0
 def test_prev_list2(self):
     s = _State()
     s.translations = [self.a, self.b]
     assert s.prev() == [self.a, self.b]
Exemplo n.º 8
0
 def test_restrict_size_to_one_on_two_strokes(self):
     s = _State()
     s.translations = [self.b]
     s.restrict_size(1)
     self.assertEquals(s.translations, [self.b])
     self.assertIsNone(s.tail)
Exemplo n.º 9
0
 def test_prev_tail0(self):
     s = _State()
     s.tail = self.b
     self.assertEqual(s.prev(), [self.b])
Exemplo n.º 10
0
 def test_restrict_size_to_exactly_one_stroke(self):
     s = _State()
     s.translations = [self.a]
     s.restrict_size(1)
     assert s.translations == [self.a]
     assert s.tail is None
Exemplo n.º 11
0
 def test_restrict_size_zero_on_one_stroke(self):
     s = _State()
     s.translations = [self.a]
     s.restrict_size(0)
     assert s.translations == [self.a]
     assert s.tail is None
Exemplo n.º 12
0
 def test_restrict_size_zero_on_empty(self):
     s = _State()
     s.restrict_size(0)
     assert s.translations == []
     assert s.tail is None
Exemplo n.º 13
0
 def test_prev_tail0(self):
     s = _State()
     s.tail = self.b
     assert s.prev() == [self.b]
Exemplo n.º 14
0
 def test_prev_tail1(self):
     s = _State()
     s.translations = [self.a]
     s.tail = self.b
     assert s.prev() == [self.a]
Exemplo n.º 15
0
 def test_prev_list2(self):
     s = _State()
     s.translations = [self.a, self.b]
     assert s.prev() == [self.a, self.b]
Exemplo n.º 16
0
 def test_prev_list2(self):
     s = _State()
     s.translations = [self.a, self.b]
     self.assertEqual(s.prev(), [self.a, self.b])
Exemplo n.º 17
0
 def test_restrict_size_to_one_on_two_strokes(self):
     s = _State()
     s.translations = [self.b]
     s.restrict_size(1)
     assert s.translations == [self.b]
     assert s.tail is None
Exemplo n.º 18
0
 def test_restrict_size_zero_on_one_stroke(self):
     s = _State()
     s.translations = [self.a]
     s.restrict_size(0)
     self.assertEquals(s.translations, [self.a])
     self.assertIsNone(s.tail)
Exemplo n.º 19
0
 def test_restrict_size_to_one_on_two_translations_too_big(self):
     s = _State()
     s.translations = [self.a, self.b]
     s.restrict_size(1)
     assert s.translations == [self.b]
     assert s.tail == self.a
Exemplo n.º 20
0
 def test_restrict_size_multiple_translations(self):
     s = _State()
     s.translations = [self.a, self.b, self.c]
     s.restrict_size(5)
     self.assertEquals(s.translations, [self.b, self.c])
     self.assertEqual(s.tail, self.a)
Exemplo n.º 21
0
 def test_restrict_size_multiple_translations(self):
     s = _State()
     s.translations = [self.a, self.b, self.c]
     s.restrict_size(5)
     assert s.translations == [self.b, self.c]
     assert s.tail == self.a
Exemplo n.º 22
0
 def test_prev_tail0(self):
     s = _State()
     s.tail = self.b
     assert s.prev() == [self.b]
Exemplo n.º 23
0
 def test_restrict_size_lose_translations(self):
     s = _State()
     s.translations = [self.a, self.b, self.c]
     s.restrict_size(2)
     self.assertEquals(s.translations, [self.c])
     self.assertEqual(s.tail, self.b)
Exemplo n.º 24
0
 def test_restrict_size_to_one_on_two_strokes(self):
     s = _State()
     s.translations = [self.b]
     s.restrict_size(1)
     assert s.translations == [self.b]
     assert s.tail is None
Exemplo n.º 25
0
 def test_prev_list0(self):
     s = _State()
     self.assertIsNone(s.prev())
Exemplo n.º 26
0
 def test_prev_list0(self):
     s = _State()
     assert s.prev() is None
Exemplo n.º 27
0
 def test_prev_list2(self):
     s = _State()
     s.translations = [self.a, self.b]
     self.assertEqual(s.prev(), [self.a, self.b])
Exemplo n.º 28
0
 def test_last_list2(self):
     s = _State()
     s.translations = [self.a, self.b]
     self.assertEqual(s.last(), self.b)        
Exemplo n.º 29
0
 def test_prev_tail1(self):
     s = _State()
     s.translations = [self.a]
     s.tail = self.b
     self.assertEqual(s.prev(), [self.a])
Exemplo n.º 30
0
 def test_last_tail0(self):
     s = _State()
     s.tail = self.b
     self.assertEqual(s.last(), self.b)
Exemplo n.º 31
0
 def test_prev_tail0(self):
     s = _State()
     s.tail = self.b
     self.assertEqual(s.prev(), [self.b])
Exemplo n.º 32
0
 def test_prev_list0(self):
     s = _State()
     self.assertIsNone(s.prev())
Exemplo n.º 33
0
 def test_restrict_size_to_one_on_two_translations_too_big(self):
     s = _State()
     s.translations = [self.a, self.b]
     s.restrict_size(1)
     self.assertEqual(s.translations, [self.b])
     self.assertEqual(s.tail, self.a)
Exemplo n.º 34
0
 def test_prev_tail1(self):
     s = _State()
     s.translations = [self.a]
     s.tail = self.b
     self.assertEqual(s.prev(), [self.a])
Exemplo n.º 35
0
 def test_restrict_size_lose_translations(self):
     s = _State()
     s.translations = [self.a, self.b, self.c]
     s.restrict_size(2)
     self.assertEqual(s.translations, [self.c])
     self.assertEqual(s.tail, self.b)
Exemplo n.º 36
0
 def test_restrict_size_zero_on_empty(self):
     s = _State()
     s.restrict_size(0)
     self.assertEquals(s.translations, [])
     self.assertIsNone(s.tail)
Exemplo n.º 37
0
 def test_restrict_size_multiple_translations(self):
     s = _State()
     s.translations = [self.a, self.b, self.c]
     s.restrict_size(5)
     self.assertEqual(s.translations, [self.b, self.c])
     self.assertEqual(s.tail, self.a)
Exemplo n.º 38
0
 def test_restrict_size_to_exactly_one_stroke(self):
     s = _State()
     s.translations = [self.a]
     s.restrict_size(1)
     self.assertEquals(s.translations, [self.a])
     self.assertIsNone(s.tail)
Exemplo n.º 39
0
 def test_last_list0(self):
     s = _State()
     self.assertIsNone(s.last())
Exemplo n.º 40
0
 def test_restrict_size_to_one_on_two_translations_too_big(self):
     s = _State()
     s.translations = [self.a, self.b]
     s.restrict_size(1)
     self.assertEquals(s.translations, [self.b])
     self.assertEqual(s.tail, self.a)
Exemplo n.º 41
0
 def test_last_list2(self):
     s = _State()
     s.translations = [self.a, self.b]
     self.assertEqual(s.last(), self.b)
Exemplo n.º 42
0
 def test_prev_list0(self):
     s = _State()
     assert s.prev() is None
Exemplo n.º 43
0
 def test_last_tail1(self):
     s = _State()
     s.translations = [self.a]
     s.tail = self.b
     self.assertEqual(s.last(), self.a)
Exemplo n.º 44
0
 def test_prev_tail1(self):
     s = _State()
     s.translations = [self.a]
     s.tail = self.b
     assert s.prev() == [self.a]
Exemplo n.º 45
0
 def test_last_tail0(self):
     s = _State()
     s.tail = self.b
     self.assertEqual(s.last(), self.b)
Exemplo n.º 46
0
 def test_restrict_size_zero_on_empty(self):
     s = _State()
     s.restrict_size(0)
     assert s.translations == []
     assert s.tail is None
Exemplo n.º 47
0
 def test_restrict_size_zero_on_empty(self):
     s = _State()
     s.restrict_size(0)
     self.assertEquals(s.translations, [])
     self.assertIsNone(s.tail)
Exemplo n.º 48
0
 def test_restrict_size_to_exactly_one_stroke(self):
     s = _State()
     s.translations = [self.a]
     s.restrict_size(1)
     assert s.translations == [self.a]
     assert s.tail is None
Exemplo n.º 49
0
 def test_restrict_size_zero_on_one_stroke(self):
     s = _State()
     s.translations = [self.a]
     s.restrict_size(0)
     self.assertEquals(s.translations, [self.a])
     self.assertIsNone(s.tail)
Exemplo n.º 50
0
 def test_restrict_size_to_one_on_two_translations_too_big(self):
     s = _State()
     s.translations = [self.a, self.b]
     s.restrict_size(1)
     assert s.translations == [self.b]
     assert s.tail == self.a
Exemplo n.º 51
0
 def test_restrict_size_to_exactly_one_stroke(self):
     s = _State()
     s.translations = [self.a]
     s.restrict_size(1)
     self.assertEquals(s.translations, [self.a])
     self.assertIsNone(s.tail)
Exemplo n.º 52
0
 def test_restrict_size_to_one_on_two_strokes(self):
     s = _State()
     s.translations = [self.b]
     s.restrict_size(1)
     self.assertEquals(s.translations, [self.b])
     self.assertIsNone(s.tail)
Exemplo n.º 53
0
 def setUp(self):
     self.d = StenoDictionary()
     self.dc = StenoDictionaryCollection()
     self.dc.set_dicts([self.d])
     self.s = _State()
     self.o = type(self).CaptureOutput()