Esempio n. 1
0
 def test_get_context(self):
     expected_context = '---\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eget urna a arcu ' \
                        'lacinia sagittis. \n' \
                        'Sed scelerisque, lacus eget malesuada vestibulum, justo diam facilisis tortor, in sodales' \
                        ' dolor \n' \
                        '[...]\n' \
                        '---'
     ret = utils.get_context(LORUM_IPSUM, 1, num_lines=1)
     self.assertEqual(ret, expected_context)
Esempio n. 2
0
 def test_get_context_with_marker(self):
     template = '1\n2\n3\n4\n5\n6\n7\n8\n9\na\nb\nc\nd\ne\nf'
     context = get_context(template, 8, num_lines=2, marker=' <---')
     expected = '---\n[...]\n6\n7\n8 <---\n9\na\n[...]\n---'
     self.assertEqual(expected, context)
Esempio n. 3
0
 def test_get_context_at_bottom_of_file(self):
     template = '1\n2\n3\n4\n5\n6\n7\n8\n9\na\nb\nc\nd\ne\nf'
     context = get_context(template, 15)
     expected = '---\n[...]\na\nb\nc\nd\ne\nf\n---'
     self.assertEqual(expected, context)
Esempio n. 4
0
 def test_get_context_has_enough_context(self):
     template = '1\n2\n3\n4\n5\n6\n7\n8\n9\na\nb\nc\nd\ne\nf'
     context = get_context(template, 8)
     expected = '---\n[...]\n3\n4\n5\n6\n7\n8\n9\na\nb\nc\nd\n[...]\n---'
     self.assertEqual(expected, context)
Esempio n. 5
0
 def test_get_context_with_marker(self):
     template = '1\n2\n3\n4\n5\n6\n7\n8\n9\na\nb\nc\nd\ne\nf'
     context = get_context(template, 8, num_lines=2, marker=' <---')
     expected = '---\n[...]\n6\n7\n8 <---\n9\na\n[...]\n---'
     self.assertEqual(expected, context)
Esempio n. 6
0
 def test_get_context_at_bottom_of_file(self):
     template = '1\n2\n3\n4\n5\n6\n7\n8\n9\na\nb\nc\nd\ne\nf'
     context = get_context(template, 15)
     expected = '---\n[...]\na\nb\nc\nd\ne\nf\n---'
     self.assertEqual(expected, context)
Esempio n. 7
0
 def test_get_context_has_enough_context(self):
     template = '1\n2\n3\n4\n5\n6\n7\n8\n9\na\nb\nc\nd\ne\nf'
     context = get_context(template, 8)
     expected = '---\n[...]\n3\n4\n5\n6\n7\n8\n9\na\nb\nc\nd\n[...]\n---'
     self.assertEqual(expected, context)