コード例 #1
0
 def test_write_bytes_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(bytes('my_history',
                              sys.getfilesystemencoding()),
                        raise_exc=True)
     self.assertTrue(isfile('my_history'))
コード例 #2
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def setUp(self):
     reset()
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     history.append('pebbles')
コード例 #3
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test_replace(self):
     history.max_entries = 5
     history.append('bammbamm')
     self.assertEqual(history[0], 'wilma')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'betty')
     self.assertEqual(history[3], 'pebbles')
     self.assertEqual(history[4], 'bammbamm')
     history[2] = 'dino'
     self.assertEqual(history[0], 'wilma')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'dino')
     self.assertEqual(history[3], 'pebbles')
     self.assertEqual(history[4], 'bammbamm')
     history[0] = 'hopper'
     self.assertEqual(history[0], 'hopper')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'dino')
     self.assertEqual(history[3], 'pebbles')
     self.assertEqual(history[4], 'bammbamm')
     history[-1] = 'bedrock'
     self.assertEqual(history[0], 'hopper')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'dino')
     self.assertEqual(history[3], 'pebbles')
     self.assertEqual(history[4], 'bedrock')
コード例 #4
0
 def test_read_tilde_expanded(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(self.histfile, raise_exc=True)
     history.clear()
     history.read_file('~/.history', raise_exc=True)
     self.assertEqual(len(history), 2)
コード例 #5
0
 def test_read_default_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(self.histfile, raise_exc=True)
     history.clear()
     history.read_file(raise_exc=True)
     self.assertEqual(len(history), 2)
コード例 #6
0
ファイル: test_history.py プロジェクト: tony/rl
 def test_replace(self):
     history.max_entries = 5
     history.append('bammbamm')
     self.assertEqual(history[0], 'wilma')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'betty')
     self.assertEqual(history[3], 'pebbles')
     self.assertEqual(history[4], 'bammbamm')
     history[2] = 'dino'
     self.assertEqual(history[0], 'wilma')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'dino')
     self.assertEqual(history[3], 'pebbles')
     self.assertEqual(history[4], 'bammbamm')
     history[0] = 'hopper'
     self.assertEqual(history[0], 'hopper')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'dino')
     self.assertEqual(history[3], 'pebbles')
     self.assertEqual(history[4], 'bammbamm')
     history[-1] = 'bedrock'
     self.assertEqual(history[0], 'hopper')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'dino')
     self.assertEqual(history[3], 'pebbles')
     self.assertEqual(history[4], 'bedrock')
コード例 #7
0
 def test_read_tilde_expanded(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(self.histfile, raise_exc=True)
     history.clear()
     history.read_file('~/.history', raise_exc=True)
     self.assertEqual(len(history), 2)
コード例 #8
0
 def test_read_bytes_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(bytes('my_history', sys.getfilesystemencoding()), raise_exc=True)
     history.clear()
     history.read_file(bytes('my_history', sys.getfilesystemencoding()), raise_exc=True)
     self.assertEqual(len(history), 2)
コード例 #9
0
 def test_read_abspath(self):
     history.append('fred')
     history.append('wilma')
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.read_file(abspath('my_history'), raise_exc=True)
     self.assertEqual(len(history), 2)
コード例 #10
0
ファイル: test_history.py プロジェクト: tony/rl
 def setUp(self):
     reset()
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     history.append('pebbles')
コード例 #11
0
 def test_read_abspath(self):
     history.append('fred')
     history.append('wilma')
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.read_file(abspath('my_history'), raise_exc=True)
     self.assertEqual(len(history), 2)
コード例 #12
0
 def test_read_None_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(self.histfile, raise_exc=True)
     history.clear()
     history.read_file(None, raise_exc=True)
     self.assertEqual(len(history), 2)
コード例 #13
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test__reversed__items(self):
     history.max_entries = 5
     history.append('bammbamm')
     self.assertEqual([x for x in reversed(history)], ['bammbamm', 'pebbles', 'betty', 'barney', 'wilma'])
     history.append('dino')
     self.assertEqual([x for x in reversed(history)], ['dino', 'bammbamm', 'pebbles', 'betty', 'barney'])
     history[0] = 'hopper'
     self.assertEqual([x for x in reversed(history)], ['dino', 'bammbamm', 'pebbles', 'betty', 'hopper'])
コード例 #14
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test__iter__items(self):
     history.max_entries = 5
     history.append('bammbamm')
     self.assertEqual([x for x in history], ['wilma', 'barney', 'betty', 'pebbles', 'bammbamm'])
     history.append('dino')
     self.assertEqual([x for x in history], ['barney', 'betty', 'pebbles', 'bammbamm', 'dino'])
     history[0] = 'hopper'
     self.assertEqual([x for x in history], ['hopper', 'betty', 'pebbles', 'bammbamm', 'dino'])
コード例 #15
0
ファイル: test_histfile.py プロジェクト: stefanholek/rl
 def test_append_relative(self):
     history.write_file('my_history', raise_exc=True)
     history.append('fred')
     history.append('wilma')
     history.append_file(2, 'my_history')
     history.clear()
     history.read_file('my_history', raise_exc=True)
     self.assertEqual(len(history), 2)
コード例 #16
0
 def test_read_bytes_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(bytes('my_history',
                              sys.getfilesystemencoding()),
                        raise_exc=True)
     history.clear()
     history.read_file(bytes('my_history', sys.getfilesystemencoding()),
                       raise_exc=True)
     self.assertEqual(len(history), 2)
コード例 #17
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test_unstifled(self):
     history.max_entries = -1
     # Extend history beyond 5 entries
     history.append('bammbamm')
     self.assertEqual(history[0], 'fred')
     self.assertEqual(history[1], 'wilma')
     self.assertEqual(history[2], 'barney')
     self.assertEqual(history[3], 'betty')
     self.assertEqual(history[4], 'pebbles')
     self.assertEqual(history[5], 'bammbamm')
     self.assertEqual(len(history), 6)
コード例 #18
0
ファイル: test_history.py プロジェクト: tony/rl
 def test__iter__items(self):
     history.max_entries = 5
     history.append('bammbamm')
     self.assertEqual([x for x in history],
                      ['wilma', 'barney', 'betty', 'pebbles', 'bammbamm'])
     history.append('dino')
     self.assertEqual([x for x in history],
                      ['barney', 'betty', 'pebbles', 'bammbamm', 'dino'])
     history[0] = 'hopper'
     self.assertEqual([x for x in history],
                      ['hopper', 'betty', 'pebbles', 'bammbamm', 'dino'])
コード例 #19
0
ファイル: test_history.py プロジェクト: tony/rl
 def test_unstifled(self):
     history.max_entries = -1
     # Extend history beyond 5 entries
     history.append('bammbamm')
     self.assertEqual(history[0], 'fred')
     self.assertEqual(history[1], 'wilma')
     self.assertEqual(history[2], 'barney')
     self.assertEqual(history[3], 'betty')
     self.assertEqual(history[4], 'pebbles')
     self.assertEqual(history[5], 'bammbamm')
     self.assertEqual(len(history), 6)
コード例 #20
0
ファイル: test_history.py プロジェクト: tony/rl
 def test__reversed__items(self):
     history.max_entries = 5
     history.append('bammbamm')
     self.assertEqual([x for x in reversed(history)],
                      ['bammbamm', 'pebbles', 'betty', 'barney', 'wilma'])
     history.append('dino')
     self.assertEqual([x for x in reversed(history)],
                      ['dino', 'bammbamm', 'pebbles', 'betty', 'barney'])
     history[0] = 'hopper'
     self.assertEqual([x for x in reversed(history)],
                      ['dino', 'bammbamm', 'pebbles', 'betty', 'hopper'])
コード例 #21
0
ファイル: test_history.py プロジェクト: tony/rl
 def test_iterate(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual([x for x in reversed(history)],
                      ['betty', 'barney', 'wilma', 'fred'])
コード例 #22
0
ファイル: test_history.py プロジェクト: tony/rl
 def test_stifle_truncates_existing(self):
     history.max_entries = -1
     # Extend history beyond 5 entries
     history.append('bammbamm')
     history.append('dino')
     self.assertEqual(len(history), 7)
     # Now stifle
     history.max_entries = 5
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'betty')
     self.assertEqual(history[2], 'pebbles')
     self.assertEqual(history[3], 'bammbamm')
     self.assertEqual(history[4], 'dino')
     self.assertEqual(len(history), 5)
コード例 #23
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test_stifle_truncates_existing(self):
     history.max_entries = -1
     # Extend history beyond 5 entries
     history.append('bammbamm')
     history.append('dino')
     self.assertEqual(len(history), 7)
     # Now stifle
     history.max_entries = 5
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'betty')
     self.assertEqual(history[2], 'pebbles')
     self.assertEqual(history[3], 'bammbamm')
     self.assertEqual(history[4], 'dino')
     self.assertEqual(len(history), 5)
コード例 #24
0
ファイル: test_histfile.py プロジェクト: stefanholek/rl
 def test_write_file_replaces_file(self):
     history.append('fred')
     history.append('wilma')
     history.append('pebbles')
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.append('barney')
     history.append('betty')
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.read_file('my_history', raise_exc=True)
     self.assertEqual(len(history), 2)
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'betty')
コード例 #25
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test__iter__items(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual(len(history), 4)
     self.assertEqual([x for x in history], ['fred', 'wilma', 'barney', 'betty'])
コード例 #26
0
ファイル: test_history.py プロジェクト: tony/rl
 def test_iterate(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual([x for x in history],
                      ['fred', 'wilma', 'barney', 'betty'])
コード例 #27
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test__reversed__items(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual(len(history), 4)
     self.assertEqual([x for x in reversed(history)], ['betty', 'barney', 'wilma', 'fred'])
コード例 #28
0
ファイル: test_history.py プロジェクト: tony/rl
 def test_set_slice(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertRaises(TypeError, history.__setitem__, slice(2, -1),
                       ['dino'])
コード例 #29
0
ファイル: test_history.py プロジェクト: tony/rl
 def test__iter__items(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual(len(history), 4)
     self.assertEqual([x for x in history],
                      ['fred', 'wilma', 'barney', 'betty'])
コード例 #30
0
ファイル: test_history.py プロジェクト: tony/rl
 def test_reversed_iterator(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertRaises(TypeError, reversed, reversed(history))
     list = ['a', 'b', 'c', 'd']
     self.assertRaises(TypeError, reversed, reversed(list))
コード例 #31
0
ファイル: test_history.py プロジェクト: tony/rl
 def test_iterate_exhausted(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     i = reversed(history)
     self.assertEqual([x for x in i], ['betty', 'barney', 'wilma', 'fred'])
     self.assertRaises(StopIteration, i.next)
コード例 #32
0
ファイル: test_history.py プロジェクト: tony/rl
 def test_out_of_range_pos(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual(len(history), 4)
     self.assertRaises(IndexError, history.__getitem__, 4)
     self.assertRaises(IndexError, history.__getitem__, -5)
コード例 #33
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test_reversed_iterator(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertRaises(TypeError, reversed, reversed(history))
     list = ['a', 'b', 'c', 'd']
     self.assertRaises(TypeError, reversed, reversed(list))
コード例 #34
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test_iterate_iterator(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual([x for x in iter(reversed(history))], ['betty', 'barney', 'wilma', 'fred'])
     list = ['a', 'b', 'c', 'd']
     self.assertEqual([x for x in iter(reversed(list))], ['d', 'c', 'b', 'a'])
コード例 #35
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test_out_of_range_pos(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual(len(history), 4)
     self.assertRaises(IndexError, history.__getitem__, 4)
     self.assertRaises(IndexError, history.__getitem__, -5)
コード例 #36
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test_iterate_exhausted(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     i = reversed(history)
     self.assertEqual([x for x in i], ['betty', 'barney', 'wilma', 'fred'])
     self.assertRaises(StopIteration, next, i)
コード例 #37
0
ファイル: test_history.py プロジェクト: tony/rl
 def test_length_hint(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     i = reversed(history)
     self.assertEqual(i.__length_hint__(), len(history))
     for n, x in enumerate(i):
         self.assertEqual(i.__length_hint__(), len(history) - n - 1)
コード例 #38
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test_length_hint(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     i = reversed(history)
     self.assertEqual(i.__length_hint__(), len(history))
     for n, x in enumerate(i):
         self.assertEqual(i.__length_hint__(), len(history)-n-1)
コード例 #39
0
ファイル: test_history.py プロジェクト: tony/rl
 def test_iterate_iterator(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual([x for x in iter(iter(history))],
                      ['fred', 'wilma', 'barney', 'betty'])
     list = ['a', 'b', 'c', 'd']
     self.assertEqual([x for x in iter(iter(list))], ['a', 'b', 'c', 'd'])
コード例 #40
0
ファイル: test_history.py プロジェクト: tony/rl
 def test_negative_pos(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual(len(history), 4)
     self.assertEqual(history[-4], 'fred')
     self.assertEqual(history[-3], 'wilma')
     self.assertEqual(history[-2], 'barney')
     self.assertEqual(history[-1], 'betty')
コード例 #41
0
 def test__getitem__(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual(len(history), 4)
     self.assertEqual(history[0], 'fred')
     self.assertEqual(history[1], 'wilma')
     self.assertEqual(history[2], 'barney')
     self.assertEqual(history[3], 'betty')
コード例 #42
0
 def test_negative_pos(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual(len(history), 4)
     self.assertEqual(history[-4], 'fred')
     self.assertEqual(history[-3], 'wilma')
     self.assertEqual(history[-2], 'barney')
     self.assertEqual(history[-1], 'betty')
コード例 #43
0
ファイル: test_history.py プロジェクト: tony/rl
 def test__getitem__(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual(len(history), 4)
     self.assertEqual(history[0], 'fred')
     self.assertEqual(history[1], 'wilma')
     self.assertEqual(history[2], 'barney')
     self.assertEqual(history[3], 'betty')
コード例 #44
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test_stifled(self):
     history.max_entries = 5
     # Extend history beyond 5 entries
     history.append('bammbamm')
     self.assertEqual(history[0], 'wilma')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'betty')
     self.assertEqual(history[3], 'pebbles')
     self.assertEqual(history[4], 'bammbamm')
     self.assertEqual(len(history), 5)
     # Add one more
     history.append('dino')
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'betty')
     self.assertEqual(history[2], 'pebbles')
     self.assertEqual(history[3], 'bammbamm')
     self.assertEqual(history[4], 'dino')
     self.assertEqual(len(history), 5)
コード例 #45
0
ファイル: test_history.py プロジェクト: tony/rl
 def test_stifled(self):
     history.max_entries = 5
     # Extend history beyond 5 entries
     history.append('bammbamm')
     self.assertEqual(history[0], 'wilma')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'betty')
     self.assertEqual(history[3], 'pebbles')
     self.assertEqual(history[4], 'bammbamm')
     self.assertEqual(len(history), 5)
     # Add one more
     history.append('dino')
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'betty')
     self.assertEqual(history[2], 'pebbles')
     self.assertEqual(history[3], 'bammbamm')
     self.assertEqual(history[4], 'dino')
     self.assertEqual(len(history), 5)
コード例 #46
0
 def test_write_file_replaces_file(self):
     history.append('fred')
     history.append('wilma')
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.append('barney')
     history.append('betty')
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.read_file('my_history', raise_exc=True)
     self.assertEqual(len(history), 2)
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'betty')
コード例 #47
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test__delitem__(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual(len(history), 4)
     del history[1]
     self.assertEqual(len(history), 3)
     self.assertEqual(history[0], 'fred')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'betty')
     del history[-2]
     self.assertEqual(len(history), 2)
     self.assertEqual(history[0], 'fred')
     self.assertEqual(history[1], 'betty')
コード例 #48
0
ファイル: test_history.py プロジェクト: tony/rl
 def test_remove(self):
     history.max_entries = 5
     history.append('bammbamm')
     self.assertEqual(history[0], 'wilma')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'betty')
     self.assertEqual(history[3], 'pebbles')
     self.assertEqual(history[4], 'bammbamm')
     del history[2]
     self.assertEqual(history[0], 'wilma')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'pebbles')
     self.assertEqual(history[3], 'bammbamm')
     self.assertEqual(len(history), 4)
     del history[0]
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'pebbles')
     self.assertEqual(history[2], 'bammbamm')
     self.assertEqual(len(history), 3)
     del history[-1]
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'pebbles')
     self.assertEqual(len(history), 2)
コード例 #49
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test_remove(self):
     history.max_entries = 5
     history.append('bammbamm')
     self.assertEqual(history[0], 'wilma')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'betty')
     self.assertEqual(history[3], 'pebbles')
     self.assertEqual(history[4], 'bammbamm')
     del history[2]
     self.assertEqual(history[0], 'wilma')
     self.assertEqual(history[1], 'barney')
     self.assertEqual(history[2], 'pebbles')
     self.assertEqual(history[3], 'bammbamm')
     self.assertEqual(len(history), 4)
     del history[0]
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'pebbles')
     self.assertEqual(history[2], 'bammbamm')
     self.assertEqual(len(history), 3)
     del history[-1]
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'pebbles')
     self.assertEqual(len(history), 2)
コード例 #50
0
ファイル: test_history.py プロジェクト: stefanholek/rl
 def test__setitem__(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     self.assertEqual(len(history), 4)
     history[1] = 'pebbles'
     self.assertEqual(len(history), 4)
     self.assertEqual(history[0], 'fred')
     self.assertEqual(history[1], 'pebbles')
     self.assertEqual(history[2], 'barney')
     self.assertEqual(history[3], 'betty')
     history[-2] = 'bammbamm'
     self.assertEqual(len(history), 4)
     self.assertEqual(history[0], 'fred')
     self.assertEqual(history[1], 'pebbles')
     self.assertEqual(history[2], 'bammbamm')
     self.assertEqual(history[3], 'betty')
コード例 #51
0
ファイル: test_histfile.py プロジェクト: stefanholek/rl
 def test_write_file_truncates_file(self):
     history.append('fred')
     history.append('wilma')
     history.append('pebbles')
     history.max_file = 2
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.read_file('my_history', raise_exc=True)
     self.assertEqual(len(history), 2)
     self.assertEqual(history[0], 'wilma')
     self.assertEqual(history[1], 'pebbles')
コード例 #52
0
 def test_write_abspath(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(abspath('my_history'), raise_exc=True)
     self.assertTrue(isfile(abspath('my_history')))
     self.assertTrue(isfile('my_history'))
コード例 #53
0
 def test_write_abspath(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(abspath('my_history'), raise_exc=True)
     self.assertTrue(isfile(abspath('my_history')))
     self.assertTrue(isfile('my_history'))
コード例 #54
0
 def test_write_None_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(None, raise_exc=True)
     self.assertTrue(isfile(self.histfile))
コード例 #55
0
 def test_write_relative(self):
     history.append('fred')
     history.append('wilma')
     history.write_file('my_history', raise_exc=True)
     self.assertTrue(isfile('my_history'))
コード例 #56
0
 def test_write_file_stifled(self):
     history.append('fred')
     history.append('wilma')
     history.append('barney')
     history.append('betty')
     history.append('pebbles')
     history.append('bammbamm')
     history.append('dino')
     self.assertEqual(len(history), 7)
     history.max_entries = 5
     history.write_file('my_history', raise_exc=True)
     history.clear()
     history.max_entries = -1
     history.read_file('my_history', raise_exc=True)
     self.assertEqual(history[0], 'barney')
     self.assertEqual(history[1], 'betty')
     self.assertEqual(history[2], 'pebbles')
     self.assertEqual(history[3], 'bammbamm')
     self.assertEqual(history[4], 'dino')
     self.assertEqual(len(history), 5)
コード例 #57
0
 def test_write_tilde_expanded(self):
     history.append('fred')
     history.append('wilma')
     history.write_file('~/.history', raise_exc=True)
     self.assertTrue(isfile(self.histfile))
コード例 #58
0
 def test_write_None_name(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(None, raise_exc=True)
     self.assertTrue(isfile(self.histfile))
コード例 #59
0
 def test_read_empty_string(self):
     history.append('fred')
     history.append('wilma')
     history.write_file(self.histfile, raise_exc=True)
     history.clear()
     self.assertRaises(IOError, history.read_file, '', raise_exc=True)
コード例 #60
0
 def test_write_relative(self):
     history.append('fred')
     history.append('wilma')
     history.write_file('my_history', raise_exc=True)
     self.assertTrue(isfile('my_history'))