How to use has_next method in Slash

Best Python code snippet using slash

test_ext_napoleon_iterators.py

Source:test_ext_napoleon_iterators.py Github

copy

Full Screen

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

Full Screen

Full Screen

get_mws_feeds_submissions_response_data.py

Source:get_mws_feeds_submissions_response_data.py Github

copy

Full Screen

...54 :type feed_submission_info: List[FeedSubmissionInfo]55 """56 self._feed_submission_info = feed_submission_info57 @property58 def has_next(self) -> str:59 """Gets the has_next of this GetMwsFeedsSubmissionsResponseData.60 :return: The has_next of this GetMwsFeedsSubmissionsResponseData.61 :rtype: str62 """63 return self._has_next64 @has_next.setter65 def has_next(self, has_next: str):66 """Sets the has_next of this GetMwsFeedsSubmissionsResponseData.67 :param has_next: The has_next of this GetMwsFeedsSubmissionsResponseData.68 :type has_next: str69 """70 self._has_next = has_next71 @property72 def next_token(self) -> str:73 """Gets the next_token of this GetMwsFeedsSubmissionsResponseData.74 :return: The next_token of this GetMwsFeedsSubmissionsResponseData.75 :rtype: str76 """77 return self._next_token78 @next_token.setter79 def next_token(self, next_token: str):...

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 Slash 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