How to use twice method in unittest-xml-reporting

Best Python code snippet using unittest-xml-reporting_python

test_ext_napoleon_iterators.py

Source:test_ext_napoleon_iterators.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2"""3 test_napoleon_iterators4 ~~~~~~~~~~~~~~~~~~~~~~~5 Tests for :mod:`sphinx.ext.napoleon.iterators` module.6 :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.7 :license: BSD, see LICENSE for details.8"""9from unittest import TestCase10from sphinx.ext.napoleon.iterators import peek_iter, modify_iter11class BaseIteratorsTest(TestCase):12 def assertEqualTwice(self, expected, func, *args):13 self.assertEqual(expected, func(*args))14 self.assertEqual(expected, func(*args))15 def assertFalseTwice(self, func, *args):16 self.assertFalse(func(*args))17 self.assertFalse(func(*args))18 def assertNext(self, it, expected, is_last):19 self.assertTrueTwice(it.has_next)20 self.assertEqualTwice(expected, it.peek)21 self.assertTrueTwice(it.has_next)22 self.assertEqualTwice(expected, it.peek)23 self.assertTrueTwice(it.has_next)24 self.assertEqual(expected, next(it))25 if is_last:26 self.assertFalseTwice(it.has_next)27 self.assertRaisesTwice(StopIteration, it.next)28 else:29 self.assertTrueTwice(it.has_next)30 def assertRaisesTwice(self, exc, func, *args):31 self.assertRaises(exc, func, *args)32 self.assertRaises(exc, func, *args)33 def assertTrueTwice(self, func, *args):34 self.assertTrue(func(*args))35 self.assertTrue(func(*args))36class PeekIterTest(BaseIteratorsTest):37 def test_init_with_sentinel(self):38 a = iter(['1', '2', 'DONE'])39 sentinel = 'DONE'40 self.assertRaises(TypeError, peek_iter, a, sentinel)41 def get_next():42 return next(a)43 it = peek_iter(get_next, sentinel)44 self.assertEqual(it.sentinel, sentinel)45 self.assertNext(it, '1', is_last=False)46 self.assertNext(it, '2', is_last=True)47 def test_iter(self):48 a = ['1', '2', '3']49 it = peek_iter(a)50 self.assertTrue(it is it.__iter__())51 a = []52 b = [i for i in peek_iter(a)]53 self.assertEqual([], b)54 a = ['1']55 b = [i for i in peek_iter(a)]56 self.assertEqual(['1'], b)57 a = ['1', '2']58 b = [i for i in peek_iter(a)]59 self.assertEqual(['1', '2'], b)60 a = ['1', '2', '3']61 b = [i for i in peek_iter(a)]62 self.assertEqual(['1', '2', '3'], b)63 def test_next_with_multi(self):64 a = []65 it = peek_iter(a)66 self.assertFalseTwice(it.has_next)67 self.assertRaisesTwice(StopIteration, it.next, 2)68 a = ['1']69 it = peek_iter(a)70 self.assertTrueTwice(it.has_next)71 self.assertRaisesTwice(StopIteration, it.next, 2)72 self.assertTrueTwice(it.has_next)73 a = ['1', '2']74 it = peek_iter(a)75 self.assertTrueTwice(it.has_next)76 self.assertEqual(['1', '2'], it.next(2))77 self.assertFalseTwice(it.has_next)78 a = ['1', '2', '3']79 it = peek_iter(a)80 self.assertTrueTwice(it.has_next)81 self.assertEqual(['1', '2'], it.next(2))82 self.assertTrueTwice(it.has_next)83 self.assertRaisesTwice(StopIteration, it.next, 2)84 self.assertTrueTwice(it.has_next)85 a = ['1', '2', '3', '4']86 it = peek_iter(a)87 self.assertTrueTwice(it.has_next)88 self.assertEqual(['1', '2'], it.next(2))89 self.assertTrueTwice(it.has_next)90 self.assertEqual(['3', '4'], it.next(2))91 self.assertFalseTwice(it.has_next)92 self.assertRaisesTwice(StopIteration, it.next, 2)93 self.assertFalseTwice(it.has_next)94 def test_next_with_none(self):95 a = []96 it = peek_iter(a)97 self.assertFalseTwice(it.has_next)98 self.assertRaisesTwice(StopIteration, it.next)99 self.assertFalseTwice(it.has_next)100 a = ['1']101 it = peek_iter(a)102 self.assertEqual('1', it.__next__())103 a = ['1']104 it = peek_iter(a)105 self.assertNext(it, '1', is_last=True)106 a = ['1', '2']107 it = peek_iter(a)108 self.assertNext(it, '1', is_last=False)109 self.assertNext(it, '2', is_last=True)110 a = ['1', '2', '3']111 it = peek_iter(a)112 self.assertNext(it, '1', is_last=False)113 self.assertNext(it, '2', is_last=False)114 self.assertNext(it, '3', is_last=True)115 def test_next_with_one(self):116 a = []117 it = peek_iter(a)118 self.assertFalseTwice(it.has_next)119 self.assertRaisesTwice(StopIteration, it.next, 1)120 a = ['1']121 it = peek_iter(a)122 self.assertTrueTwice(it.has_next)123 self.assertEqual(['1'], it.next(1))124 self.assertFalseTwice(it.has_next)125 self.assertRaisesTwice(StopIteration, it.next, 1)126 a = ['1', '2']127 it = peek_iter(a)128 self.assertTrueTwice(it.has_next)129 self.assertEqual(['1'], it.next(1))130 self.assertTrueTwice(it.has_next)131 self.assertEqual(['2'], it.next(1))132 self.assertFalseTwice(it.has_next)133 self.assertRaisesTwice(StopIteration, it.next, 1)134 def test_next_with_zero(self):135 a = []136 it = peek_iter(a)137 self.assertFalseTwice(it.has_next)138 self.assertRaisesTwice(StopIteration, it.next, 0)139 a = ['1']140 it = peek_iter(a)141 self.assertTrueTwice(it.has_next)142 self.assertEqualTwice([], it.next, 0)143 self.assertTrueTwice(it.has_next)144 self.assertEqualTwice([], it.next, 0)145 a = ['1', '2']146 it = peek_iter(a)147 self.assertTrueTwice(it.has_next)148 self.assertEqualTwice([], it.next, 0)149 self.assertTrueTwice(it.has_next)150 self.assertEqualTwice([], it.next, 0)151 def test_peek_with_multi(self):152 a = []153 it = peek_iter(a)154 self.assertFalseTwice(it.has_next)155 self.assertEqualTwice([it.sentinel, it.sentinel], it.peek, 2)156 self.assertFalseTwice(it.has_next)157 a = ['1']158 it = peek_iter(a)159 self.assertTrueTwice(it.has_next)160 self.assertEqualTwice(['1', it.sentinel], it.peek, 2)161 self.assertTrueTwice(it.has_next)162 self.assertEqualTwice(['1', it.sentinel, it.sentinel], it.peek, 3)163 self.assertTrueTwice(it.has_next)164 a = ['1', '2']165 it = peek_iter(a)166 self.assertTrueTwice(it.has_next)167 self.assertEqualTwice(['1', '2'], it.peek, 2)168 self.assertTrueTwice(it.has_next)169 self.assertEqualTwice(['1', '2', it.sentinel], it.peek, 3)170 self.assertTrueTwice(it.has_next)171 self.assertEqualTwice(['1', '2', it.sentinel, it.sentinel], it.peek, 4)172 self.assertTrueTwice(it.has_next)173 a = ['1', '2', '3']174 it = peek_iter(a)175 self.assertTrueTwice(it.has_next)176 self.assertEqualTwice(['1', '2'], it.peek, 2)177 self.assertTrueTwice(it.has_next)178 self.assertEqualTwice(['1', '2', '3'], it.peek, 3)179 self.assertTrueTwice(it.has_next)180 self.assertEqualTwice(['1', '2', '3', it.sentinel], it.peek, 4)181 self.assertTrueTwice(it.has_next)182 self.assertEqual('1', next(it))183 self.assertTrueTwice(it.has_next)184 self.assertEqualTwice(['2', '3'], it.peek, 2)185 self.assertTrueTwice(it.has_next)186 self.assertEqualTwice(['2', '3', it.sentinel], it.peek, 3)187 self.assertTrueTwice(it.has_next)188 self.assertEqualTwice(['2', '3', it.sentinel, it.sentinel], it.peek, 4)189 self.assertTrueTwice(it.has_next)190 def test_peek_with_none(self):191 a = []192 it = peek_iter(a)193 self.assertFalseTwice(it.has_next)194 self.assertEqualTwice(it.sentinel, it.peek)195 self.assertFalseTwice(it.has_next)196 a = ['1']197 it = peek_iter(a)198 self.assertTrueTwice(it.has_next)199 self.assertEqualTwice('1', it.peek)200 self.assertEqual('1', next(it))201 self.assertFalseTwice(it.has_next)202 self.assertEqualTwice(it.sentinel, it.peek)203 self.assertFalseTwice(it.has_next)204 a = ['1', '2']205 it = peek_iter(a)206 self.assertTrueTwice(it.has_next)207 self.assertEqualTwice('1', it.peek)208 self.assertEqual('1', next(it))209 self.assertTrueTwice(it.has_next)210 self.assertEqualTwice('2', it.peek)211 self.assertEqual('2', next(it))212 self.assertFalseTwice(it.has_next)213 self.assertEqualTwice(it.sentinel, it.peek)214 self.assertFalseTwice(it.has_next)215 def test_peek_with_one(self):216 a = []217 it = peek_iter(a)218 self.assertFalseTwice(it.has_next)219 self.assertEqualTwice([it.sentinel], it.peek, 1)220 self.assertFalseTwice(it.has_next)221 a = ['1']222 it = peek_iter(a)223 self.assertTrueTwice(it.has_next)224 self.assertEqualTwice(['1'], it.peek, 1)225 self.assertEqual('1', next(it))226 self.assertFalseTwice(it.has_next)227 self.assertEqualTwice([it.sentinel], it.peek, 1)228 self.assertFalseTwice(it.has_next)229 a = ['1', '2']230 it = peek_iter(a)231 self.assertTrueTwice(it.has_next)232 self.assertEqualTwice(['1'], it.peek, 1)233 self.assertEqual('1', next(it))234 self.assertTrueTwice(it.has_next)235 self.assertEqualTwice(['2'], it.peek, 1)236 self.assertEqual('2', next(it))237 self.assertFalseTwice(it.has_next)238 self.assertEqualTwice([it.sentinel], it.peek, 1)239 self.assertFalseTwice(it.has_next)240 def test_peek_with_zero(self):241 a = []242 it = peek_iter(a)243 self.assertFalseTwice(it.has_next)244 self.assertEqualTwice([], it.peek, 0)245 a = ['1']246 it = peek_iter(a)247 self.assertTrueTwice(it.has_next)248 self.assertEqualTwice([], it.peek, 0)249 self.assertTrueTwice(it.has_next)250 self.assertEqualTwice([], it.peek, 0)251 a = ['1', '2']252 it = peek_iter(a)253 self.assertTrueTwice(it.has_next)254 self.assertEqualTwice([], it.peek, 0)255 self.assertTrueTwice(it.has_next)256 self.assertEqualTwice([], it.peek, 0)257class ModifyIterTest(BaseIteratorsTest):258 def test_init_with_sentinel_args(self):259 a = iter(['1', '2', '3', 'DONE'])260 sentinel = 'DONE'261 def get_next():262 return next(a)263 it = modify_iter(get_next, sentinel, int)264 expected = [1, 2, 3]265 self.assertEqual(expected, [i for i in it])266 def test_init_with_sentinel_kwargs(self):267 a = iter([1, 2, 3, 4])268 sentinel = 4269 def get_next():270 return next(a)271 it = modify_iter(get_next, sentinel, modifier=str)272 expected = ['1', '2', '3']273 self.assertEqual(expected, [i for i in it])274 def test_modifier_default(self):275 a = ['', ' ', ' a ', 'b ', ' c', ' ', '']276 it = modify_iter(a)277 expected = ['', ' ', ' a ', 'b ', ' c', ' ', '']278 self.assertEqual(expected, [i for i in it])279 def test_modifier_not_callable(self):280 self.assertRaises(TypeError, modify_iter, [1], modifier='not_callable')281 def test_modifier_rstrip(self):282 a = ['', ' ', ' a ', 'b ', ' c', ' ', '']283 it = modify_iter(a, modifier=lambda s: s.rstrip())284 expected = ['', '', ' a', 'b', ' c', '', '']285 self.assertEqual(expected, [i for i in it])286 def test_modifier_rstrip_unicode(self):287 a = [u'', u' ', u' a ', u'b ', u' c', u' ', u'']288 it = modify_iter(a, modifier=lambda s: s.rstrip())289 expected = [u'', u'', u' a', u'b', u' c', u'', u'']...

Full Screen

Full Screen

test_napoleon_iterators.py

Source:test_napoleon_iterators.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2"""3 test_napoleon_iterators4 ~~~~~~~~~~~~~~~~~~~~~~~5 Tests for :mod:`sphinx.ext.napoleon.iterators` module.6 :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.7 :license: BSD, see LICENSE for details.8"""9from sphinx.ext.napoleon.iterators import peek_iter, modify_iter10from unittest import TestCase11class BaseIteratorsTest(TestCase):12 def assertEqualTwice(self, expected, func, *args):13 self.assertEqual(expected, func(*args))14 self.assertEqual(expected, func(*args))15 def assertFalseTwice(self, func, *args):16 self.assertFalse(func(*args))17 self.assertFalse(func(*args))18 def assertNext(self, it, expected, is_last):19 self.assertTrueTwice(it.has_next)20 self.assertEqualTwice(expected, it.peek)21 self.assertTrueTwice(it.has_next)22 self.assertEqualTwice(expected, it.peek)23 self.assertTrueTwice(it.has_next)24 self.assertEqual(expected, next(it))25 if is_last:26 self.assertFalseTwice(it.has_next)27 self.assertRaisesTwice(StopIteration, it.next)28 else:29 self.assertTrueTwice(it.has_next)30 def assertRaisesTwice(self, exc, func, *args):31 self.assertRaises(exc, func, *args)32 self.assertRaises(exc, func, *args)33 def assertTrueTwice(self, func, *args):34 self.assertTrue(func(*args))35 self.assertTrue(func(*args))36class PeekIterTest(BaseIteratorsTest):37 def test_init_with_sentinel(self):38 a = iter(['1', '2', 'DONE'])39 sentinel = 'DONE'40 self.assertRaises(TypeError, peek_iter, a, sentinel)41 def get_next():42 return next(a)43 it = peek_iter(get_next, sentinel)44 self.assertEqual(it.sentinel, sentinel)45 self.assertNext(it, '1', is_last=False)46 self.assertNext(it, '2', is_last=True)47 def test_iter(self):48 a = ['1', '2', '3']49 it = peek_iter(a)50 self.assertTrue(it is it.__iter__())51 a = []52 b = [i for i in peek_iter(a)]53 self.assertEqual([], b)54 a = ['1']55 b = [i for i in peek_iter(a)]56 self.assertEqual(['1'], b)57 a = ['1', '2']58 b = [i for i in peek_iter(a)]59 self.assertEqual(['1', '2'], b)60 a = ['1', '2', '3']61 b = [i for i in peek_iter(a)]62 self.assertEqual(['1', '2', '3'], b)63 def test_next_with_multi(self):64 a = []65 it = peek_iter(a)66 self.assertFalseTwice(it.has_next)67 self.assertRaisesTwice(StopIteration, it.next, 2)68 a = ['1']69 it = peek_iter(a)70 self.assertTrueTwice(it.has_next)71 self.assertRaisesTwice(StopIteration, it.next, 2)72 self.assertTrueTwice(it.has_next)73 a = ['1', '2']74 it = peek_iter(a)75 self.assertTrueTwice(it.has_next)76 self.assertEqual(['1', '2'], it.next(2))77 self.assertFalseTwice(it.has_next)78 a = ['1', '2', '3']79 it = peek_iter(a)80 self.assertTrueTwice(it.has_next)81 self.assertEqual(['1', '2'], it.next(2))82 self.assertTrueTwice(it.has_next)83 self.assertRaisesTwice(StopIteration, it.next, 2)84 self.assertTrueTwice(it.has_next)85 a = ['1', '2', '3', '4']86 it = peek_iter(a)87 self.assertTrueTwice(it.has_next)88 self.assertEqual(['1', '2'], it.next(2))89 self.assertTrueTwice(it.has_next)90 self.assertEqual(['3', '4'], it.next(2))91 self.assertFalseTwice(it.has_next)92 self.assertRaisesTwice(StopIteration, it.next, 2)93 self.assertFalseTwice(it.has_next)94 def test_next_with_none(self):95 a = []96 it = peek_iter(a)97 self.assertFalseTwice(it.has_next)98 self.assertRaisesTwice(StopIteration, it.next)99 self.assertFalseTwice(it.has_next)100 a = ['1']101 it = peek_iter(a)102 self.assertEqual('1', it.__next__())103 a = ['1']104 it = peek_iter(a)105 self.assertNext(it, '1', is_last=True)106 a = ['1', '2']107 it = peek_iter(a)108 self.assertNext(it, '1', is_last=False)109 self.assertNext(it, '2', is_last=True)110 a = ['1', '2', '3']111 it = peek_iter(a)112 self.assertNext(it, '1', is_last=False)113 self.assertNext(it, '2', is_last=False)114 self.assertNext(it, '3', is_last=True)115 def test_next_with_one(self):116 a = []117 it = peek_iter(a)118 self.assertFalseTwice(it.has_next)119 self.assertRaisesTwice(StopIteration, it.next, 1)120 a = ['1']121 it = peek_iter(a)122 self.assertTrueTwice(it.has_next)123 self.assertEqual(['1'], it.next(1))124 self.assertFalseTwice(it.has_next)125 self.assertRaisesTwice(StopIteration, it.next, 1)126 a = ['1', '2']127 it = peek_iter(a)128 self.assertTrueTwice(it.has_next)129 self.assertEqual(['1'], it.next(1))130 self.assertTrueTwice(it.has_next)131 self.assertEqual(['2'], it.next(1))132 self.assertFalseTwice(it.has_next)133 self.assertRaisesTwice(StopIteration, it.next, 1)134 def test_next_with_zero(self):135 a = []136 it = peek_iter(a)137 self.assertFalseTwice(it.has_next)138 self.assertRaisesTwice(StopIteration, it.next, 0)139 a = ['1']140 it = peek_iter(a)141 self.assertTrueTwice(it.has_next)142 self.assertEqualTwice([], it.next, 0)143 self.assertTrueTwice(it.has_next)144 self.assertEqualTwice([], it.next, 0)145 a = ['1', '2']146 it = peek_iter(a)147 self.assertTrueTwice(it.has_next)148 self.assertEqualTwice([], it.next, 0)149 self.assertTrueTwice(it.has_next)150 self.assertEqualTwice([], it.next, 0)151 def test_peek_with_multi(self):152 a = []153 it = peek_iter(a)154 self.assertFalseTwice(it.has_next)155 self.assertEqualTwice([it.sentinel, it.sentinel], it.peek, 2)156 self.assertFalseTwice(it.has_next)157 a = ['1']158 it = peek_iter(a)159 self.assertTrueTwice(it.has_next)160 self.assertEqualTwice(['1', it.sentinel], it.peek, 2)161 self.assertTrueTwice(it.has_next)162 self.assertEqualTwice(['1', it.sentinel, it.sentinel], it.peek, 3)163 self.assertTrueTwice(it.has_next)164 a = ['1', '2']165 it = peek_iter(a)166 self.assertTrueTwice(it.has_next)167 self.assertEqualTwice(['1', '2'], it.peek, 2)168 self.assertTrueTwice(it.has_next)169 self.assertEqualTwice(['1', '2', it.sentinel], it.peek, 3)170 self.assertTrueTwice(it.has_next)171 self.assertEqualTwice(['1', '2', it.sentinel, it.sentinel], it.peek, 4)172 self.assertTrueTwice(it.has_next)173 a = ['1', '2', '3']174 it = peek_iter(a)175 self.assertTrueTwice(it.has_next)176 self.assertEqualTwice(['1', '2'], it.peek, 2)177 self.assertTrueTwice(it.has_next)178 self.assertEqualTwice(['1', '2', '3'], it.peek, 3)179 self.assertTrueTwice(it.has_next)180 self.assertEqualTwice(['1', '2', '3', it.sentinel], it.peek, 4)181 self.assertTrueTwice(it.has_next)182 self.assertEqual('1', next(it))183 self.assertTrueTwice(it.has_next)184 self.assertEqualTwice(['2', '3'], it.peek, 2)185 self.assertTrueTwice(it.has_next)186 self.assertEqualTwice(['2', '3', it.sentinel], it.peek, 3)187 self.assertTrueTwice(it.has_next)188 self.assertEqualTwice(['2', '3', it.sentinel, it.sentinel], it.peek, 4)189 self.assertTrueTwice(it.has_next)190 def test_peek_with_none(self):191 a = []192 it = peek_iter(a)193 self.assertFalseTwice(it.has_next)194 self.assertEqualTwice(it.sentinel, it.peek)195 self.assertFalseTwice(it.has_next)196 a = ['1']197 it = peek_iter(a)198 self.assertTrueTwice(it.has_next)199 self.assertEqualTwice('1', it.peek)200 self.assertEqual('1', next(it))201 self.assertFalseTwice(it.has_next)202 self.assertEqualTwice(it.sentinel, it.peek)203 self.assertFalseTwice(it.has_next)204 a = ['1', '2']205 it = peek_iter(a)206 self.assertTrueTwice(it.has_next)207 self.assertEqualTwice('1', it.peek)208 self.assertEqual('1', next(it))209 self.assertTrueTwice(it.has_next)210 self.assertEqualTwice('2', it.peek)211 self.assertEqual('2', next(it))212 self.assertFalseTwice(it.has_next)213 self.assertEqualTwice(it.sentinel, it.peek)214 self.assertFalseTwice(it.has_next)215 def test_peek_with_one(self):216 a = []217 it = peek_iter(a)218 self.assertFalseTwice(it.has_next)219 self.assertEqualTwice([it.sentinel], it.peek, 1)220 self.assertFalseTwice(it.has_next)221 a = ['1']222 it = peek_iter(a)223 self.assertTrueTwice(it.has_next)224 self.assertEqualTwice(['1'], it.peek, 1)225 self.assertEqual('1', next(it))226 self.assertFalseTwice(it.has_next)227 self.assertEqualTwice([it.sentinel], it.peek, 1)228 self.assertFalseTwice(it.has_next)229 a = ['1', '2']230 it = peek_iter(a)231 self.assertTrueTwice(it.has_next)232 self.assertEqualTwice(['1'], it.peek, 1)233 self.assertEqual('1', next(it))234 self.assertTrueTwice(it.has_next)235 self.assertEqualTwice(['2'], it.peek, 1)236 self.assertEqual('2', next(it))237 self.assertFalseTwice(it.has_next)238 self.assertEqualTwice([it.sentinel], it.peek, 1)239 self.assertFalseTwice(it.has_next)240 def test_peek_with_zero(self):241 a = []242 it = peek_iter(a)243 self.assertFalseTwice(it.has_next)244 self.assertEqualTwice([], it.peek, 0)245 a = ['1']246 it = peek_iter(a)247 self.assertTrueTwice(it.has_next)248 self.assertEqualTwice([], it.peek, 0)249 self.assertTrueTwice(it.has_next)250 self.assertEqualTwice([], it.peek, 0)251 a = ['1', '2']252 it = peek_iter(a)253 self.assertTrueTwice(it.has_next)254 self.assertEqualTwice([], it.peek, 0)255 self.assertTrueTwice(it.has_next)256 self.assertEqualTwice([], it.peek, 0)257class ModifyIterTest(BaseIteratorsTest):258 def test_init_with_sentinel_args(self):259 a = iter(['1', '2', '3', 'DONE'])260 sentinel = 'DONE'261 def get_next():262 return next(a)263 it = modify_iter(get_next, sentinel, int)264 expected = [1, 2, 3]265 self.assertEqual(expected, [i for i in it])266 def test_init_with_sentinel_kwargs(self):267 a = iter([1, 2, 3, 4])268 sentinel = 4269 def get_next():270 return next(a)271 it = modify_iter(get_next, sentinel, modifier=str)272 expected = ['1', '2', '3']273 self.assertEqual(expected, [i for i in it])274 def test_modifier_default(self):275 a = ['', ' ', ' a ', 'b ', ' c', ' ', '']276 it = modify_iter(a)277 expected = ['', ' ', ' a ', 'b ', ' c', ' ', '']278 self.assertEqual(expected, [i for i in it])279 def test_modifier_not_callable(self):280 self.assertRaises(TypeError, modify_iter, [1], modifier='not_callable')281 def test_modifier_rstrip(self):282 a = ['', ' ', ' a ', 'b ', ' c', ' ', '']283 it = modify_iter(a, modifier=lambda s: s.rstrip())284 expected = ['', '', ' a', 'b', ' c', '', '']285 self.assertEqual(expected, [i for i in it])286 def test_modifier_rstrip_unicode(self):287 a = [u'', u' ', u' a ', u'b ', u' c', u' ', u'']288 it = modify_iter(a, modifier=lambda s: s.rstrip())289 expected = [u'', u'', u' a', u'b', u' c', u'', u'']...

Full Screen

Full Screen

exercise_3_2_2-5.py

Source:exercise_3_2_2-5.py Github

copy

Full Screen

1'''2This function receives two arguments (a function and a variable)3and runs twice the function with the parameter/variable:4'''5def do_twice(function, argument):6 function(argument)7 function(argument)8'''9A function presented in this chapter for printing twice,10do_twice ismore general than print_twice:11'''12def print_twice(argument):13 print(argument)14 print(argument)15'''16This function uses do_twice twice for runs the function17with the parameter four times:18'''19def do_four(function, argument):20 do_twice(function, argument)21 do_twice(function, argument)22print("do_twice:\n")23do_twice(print, "spam")24print("\ndo_four:\n")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run unittest-xml-reporting automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful