How to use test_run_success method in autotest

Best Python code snippet using autotest_python

test_state.py

Source:test_state.py Github

copy

Full Screen

...43 self._state = ForState()44 self._intent = Intent()45 @ddt.data(("for", UserState))46 @ddt.unpack47 def test_run_success(self, token: str, successor_state: type) -> None:48 self.assertIsInstance(self._state.run(token, self._intent), successor_state)49 @ddt.data(("invalid", IllegalTransitionError))50 @ddt.unpack51 def test_run_error(self, token: str, exception: Type[Exception]) -> None:52 self.assertRaises(exception, self._state.run, token, self._intent)53@ddt.ddt54class TestUserState(unittest.TestCase):55 def setUp(self) -> None:56 self._state = UserState()57 self._intent = Intent()58 @ddt.data("client")59 def test_run(self, user: str) -> None:60 self.assertIsInstance(self._state.run(user, self._intent), InSelectState)61 @ddt.data("client")62 def test_validate(self, user: str) -> None:63 self._state._validate(user, self._intent)64 self.assertIn(user, self._intent.users)65@ddt.ddt66class TestInSelectState(unittest.TestCase):67 def setUp(self) -> None:68 self._state = InSelectState(UserState())69 self._intent = Intent()70 @ddt.data(71 *((token, UserState) for token in {"and", ","}),72 ("in", TheState), ("select", TheBlockchainState),73 )74 @ddt.unpack75 def test_run_success(self, token: str, successor_state: type) -> None:76 self.assertIsInstance(self._state.run(token, self._intent), successor_state)77 @ddt.data(("invalid", IllegalTransitionError))78 @ddt.unpack79 def test_run_error(self, token: str, exception: Type[Exception]) -> None:80 self.assertRaises(exception, self._state.run, token, self._intent)81@ddt.ddt82class TestTheState(unittest.TestCase):83 def setUp(self) -> None:84 self._state = TheState()85 self._intent = Intent()86 @ddt.data(("the", TimeframeState))87 @ddt.unpack88 def test_run_success(self, token: str, successor_state: type) -> None:89 self.assertIsInstance(self._state.run(token, self._intent), successor_state)90 @ddt.data(("invalid", IllegalTransitionError))91 @ddt.unpack92 def test_run_error(self, token: str, exception: Type[Exception]) -> None:93 self.assertRaises(exception, self._state.run, token, self._intent)94@ddt.ddt95class TestTimeframeState(unittest.TestCase):96 def setUp(self) -> None:97 self._state = TimeframeState()98 self._intent = Intent()99 @ddt.data(*((timeframe.value, SelectState) for timeframe in Timeframe))100 @ddt.unpack101 def test_run_success(self, token: str, successor_state: type) -> None:102 self.assertIsInstance(self._state.run(token, self._intent), successor_state)103 @ddt.data(("invalid", IllegalTransitionError))104 @ddt.unpack105 def test_run_error(self, token: str, exception: Type[Exception]) -> None:106 self.assertRaises(exception, self._state.run, token, self._intent)107 @ddt.data(*Timeframe)108 def test_validate(self, timeframe: Timeframe) -> None:109 self._state._validate(timeframe.value, self._intent)110 self.assertEqual(self._intent.timeframe, timeframe)111@ddt.ddt112class TestSelectState(unittest.TestCase):113 def setUp(self) -> None:114 self._state = SelectState()115 self._intent = Intent()116 @ddt.data(("select", TheBlockchainState))117 @ddt.unpack118 def test_run_success(self, token: str, successor_state: type) -> None:119 self.assertIsInstance(self._state.run(token, self._intent), successor_state)120 @ddt.data(("invalid", IllegalTransitionError))121 @ddt.unpack122 def test_run_error(self, token: str, exception: Type[Exception]) -> None:123 self.assertRaises(exception, self._state.run, token, self._intent)124@ddt.ddt125class TestTheBlockchainState(unittest.TestCase):126 def setUp(self) -> None:127 self._state = TheBlockchainState()128 self._intent = Intent()129 @ddt.data(130 *((blockchain.value, WithUntilAsState) for blockchain in Blockchain),131 ("the", ProfileState),132 )133 @ddt.unpack134 def test_run_success(self, token: str, successor_state: type) -> None:135 self.assertIsInstance(self._state.run(token, self._intent), successor_state)136 @ddt.data(("invalid", IllegalTransitionError))137 @ddt.unpack138 def test_run_error(self, token: str, exception: Type[Exception]) -> None:139 self.assertRaises(exception, self._state.run, token, self._intent)140 @ddt.data(*Blockchain)141 def test_validate_success(self, blockchain: Blockchain) -> None:142 self._state._validate(blockchain.value, self._intent)143 self.assertEqual(self._intent.blockchain, blockchain)144 def test_validate_error(self) -> None:145 self._state._validate("invalid", self._intent)146 self.assertIsNone(self._intent.blockchain)147@ddt.ddt148class TestWithUntilUseState(unittest.TestCase):149 def setUp(self) -> None:150 self._state = WithUntilAsState()151 self._intent = Intent()152 @ddt.data(("with", ModifierState), ("until", The2State), ("as", DefaultState))153 @ddt.unpack154 def test_run_success(self, token: str, successor_state: type) -> None:155 self.assertIsInstance(self._state.run(token, self._intent), successor_state)156 @ddt.data(("invalid", IllegalTransitionError))157 @ddt.unpack158 def test_run_error(self, token: str, exception: Type[Exception]) -> None:159 self.assertRaises(exception, self._state.run, token, self._intent)160@ddt.ddt161class TestProfileState(unittest.TestCase):162 def setUp(self) -> None:163 self._state = ProfileState()164 self._intent = Intent()165 @ddt.data(*((profile.value, FilterBlockchainState) for profile in Profile))166 @ddt.unpack167 def test_run_success(self, token: str, successor_state: type) -> None:168 self.assertIsInstance(self._state.run(token, self._intent), successor_state)169 @ddt.data(("invalid", IllegalTransitionError))170 @ddt.unpack171 def test_run_error(self, token: str, exception: Type[Exception]) -> None:172 self.assertRaises(exception, self._state.run, token, self._intent)173 @ddt.data(*Profile)174 def test_validate(self, profile: Profile) -> None:175 self._state._validate(profile.value, self._intent)176 self.assertEqual(self._intent.profile, profile)177@ddt.ddt178class TestFilterStateValidator(unittest.TestCase):179 def setUp(self) -> None:180 self._validator = FilterStateValidator()181 self._intent = Intent()182 @ddt.data(*Filter)183 def test_validate_success(self, filter_: Filter) -> None:184 self._validator.validate(filter_.value, self._intent)185 self.assertIn(filter_, self._intent.filters)186 def test_validate_error(self) -> None:187 self._validator.validate("invalid", self._intent)188 self.assertSetEqual(self._intent.filters, set())189 def test_validate_private_public(self) -> None:190 self._intent.filters.add(Filter.PRIVATE)191 self.assertRaises(192 ValidationError,193 self._validator.validate,194 Filter.PUBLIC.value,195 self._intent,196 )197 @ddt.data((Profile.CHEAPEST, Filter.CHEAP), (Profile.FASTEST, Filter.FAST))198 @ddt.unpack199 def test_validate_profile_filter(self, profile: Profile, filter_: Filter) -> None:200 self._intent.profile = profile201 self._validator.validate(filter_.value, self._intent)202 self.assertNotIn(filter_, self._intent.filters)203@ddt.ddt204class TestFilterBlockchainState(unittest.TestCase):205 def setUp(self) -> None:206 self._state = FilterBlockchainState()207 self._intent = Intent()208 @ddt.data(209 *((filter_.value, BlockchainState) for filter_ in Filter),210 ("blockchain", FromExceptWithUntilAsState),211 )212 @ddt.unpack213 def test_run_success(self, token: str, successor_state: type) -> None:214 self.assertIsInstance(self._state.run(token, self._intent), successor_state)215 @ddt.data(("invalid", IllegalTransitionError))216 @ddt.unpack217 def test_run_error(self, token: str, exception: Type[Exception]) -> None:218 self.assertRaises(exception, self._state.run, token, self._intent)219@ddt.ddt220class TestFilterState(unittest.TestCase):221 def setUp(self) -> None:222 self._state = FilterState()223 self._intent = Intent()224 @ddt.data(*((filter_.value, BlockchainState) for filter_ in Filter))225 @ddt.unpack226 def test_run_success(self, token: str, successor_state: type) -> None:227 self.assertIsInstance(self._state.run(token, self._intent), successor_state)228 @ddt.data(("invalid", IllegalTransitionError))229 @ddt.unpack230 def test_run_error(self, token: str, exception: Type[Exception]) -> None:231 self.assertRaises(exception, self._state.run, token, self._intent)232@ddt.ddt233class TestBlockchainState(unittest.TestCase):234 def setUp(self) -> None:235 self._state = BlockchainState(FilterState())236 self._intent = Intent()237 @ddt.data(238 *((token, FilterState) for token in {"and", ","}),239 ("blockchain", FromExceptWithUntilAsState),240 )241 @ddt.unpack242 def test_run_success(self, token: str, successor_state: type) -> None:243 self.assertIsInstance(self._state.run(token, self._intent), successor_state)244 @ddt.data(("invalid", IllegalTransitionError))245 @ddt.unpack246 def test_run_error(self, token: str, exception: Type[Exception]) -> None:247 self.assertRaises(exception, self._state.run, token, self._intent)248@ddt.ddt249class TestFromExceptWithUntilUseState(unittest.TestCase):250 def setUp(self) -> None:251 self._state = FromExceptWithUntilAsState()252 self._intent = Intent()253 @ddt.data(254 ("from", WhitelistState),255 ("except", BlacklistState),256 ("with", ModifierState),257 ("until", The2State),258 ("as", DefaultState),259 )260 @ddt.unpack261 def test_run_success(self, token: str, successor_state: type) -> None:262 self.assertIsInstance(self._state.run(token, self._intent), successor_state)263 @ddt.data(("invalid", IllegalTransitionError))264 @ddt.unpack265 def test_run_error(self, token: str, exception: Type[Exception]) -> None:266 self.assertRaises(exception, self._state.run, token, self._intent)267@ddt.ddt268class TestWhitelistState(unittest.TestCase):269 def setUp(self) -> None:270 self._state = WhitelistState()271 self._intent = Intent()272 @ddt.data(*((blockchain.value, WhitelistWithUntilAsState) for blockchain in Blockchain))273 @ddt.unpack274 def test_run_success(self, token: str, successor_state: type) -> None:275 self.assertIsInstance(self._state.run(token, self._intent), successor_state)276 @ddt.data(("invalid", IllegalTransitionError))277 @ddt.unpack278 def test_run_error(self, token: str, exception: Type[Exception]) -> None:279 self.assertRaises(exception, self._state.run, token, self._intent)280 @ddt.data(*Blockchain)281 def test_validate(self, blockchain: Blockchain) -> None:282 self._state._validate(blockchain.value, self._intent)283 self.assertIn(blockchain, self._intent.whitelist)284@ddt.ddt285class TestWhitelistWithUntilUseState(unittest.TestCase):286 def setUp(self) -> None:287 self._state = WhitelistWithUntilAsState(WhitelistState())288 self._intent = Intent()289 @ddt.data(290 *((token, WhitelistState) for token in {"and", ","}),291 ("with", ModifierState),292 ("until", The2State),293 ("as", DefaultState),294 )295 @ddt.unpack296 def test_run_success(self, token: str, successor_state: type) -> None:297 self.assertIsInstance(self._state.run(token, self._intent), successor_state)298 @ddt.data(("invalid", IllegalTransitionError))299 @ddt.unpack300 def test_run_error(self, token: str, exception: Type[Exception]) -> None:301 self.assertRaises(exception, self._state.run, token, self._intent)302@ddt.ddt303class TestBlacklistState(unittest.TestCase):304 def setUp(self) -> None:305 self._state = BlacklistState()306 self._intent = Intent()307 @ddt.data(*((blockchain.value, BlacklistWithUntilAsState) for blockchain in Blockchain))308 @ddt.unpack309 def test_run_success(self, token: str, successor_state: type) -> None:310 self.assertIsInstance(self._state.run(token, self._intent), successor_state)311 @ddt.data(("invalid", IllegalTransitionError))312 @ddt.unpack313 def test_run_error(self, token: str, exception: Type[Exception]) -> None:314 self.assertRaises(exception, self._state.run, token, self._intent)315 @ddt.data(*Blockchain)316 def test_validate(self, blockchain: Blockchain) -> None:317 self._state._validate(blockchain.value, self._intent)318 self.assertIn(blockchain, self._intent.blacklist)319@ddt.ddt320class TestBlacklistWithUntilAsState(unittest.TestCase):321 def setUp(self) -> None:322 self._state = BlacklistWithUntilAsState(BlacklistState())323 self._intent = Intent()324 @ddt.data(325 *((token, BlacklistState) for token in {"and", ","}),326 ("with", ModifierState),327 ("until", The2State),328 ("as", DefaultState),329 )330 @ddt.unpack331 def test_run_success(self, token: str, successor_state: type) -> None:332 self.assertIsInstance(self._state.run(token, self._intent), successor_state)333 @ddt.data(("invalid", IllegalTransitionError))334 @ddt.unpack335 def test_run_error(self, token: str, exception: Type[Exception]) -> None:336 self.assertRaises(exception, self._state.run, token, self._intent)337@ddt.ddt338class TestModifierState(unittest.TestCase):339 def setUp(self) -> None:340 self._state = ModifierState()341 self._intent = Intent()342 @ddt.data(*((modifier.value, UntilAsState) for modifier in Modifier))343 @ddt.unpack344 def test_run_success(self, token: str, successor_state: type) -> None:345 self.assertIsInstance(self._state.run(token, self._intent), successor_state)346 @ddt.data(("invalid", IllegalTransitionError))347 @ddt.unpack348 def test_run_error(self, token: str, exception: Type[Exception]) -> None:349 self.assertRaises(exception, self._state.run, token, self._intent)350 @ddt.data(*Modifier)351 def test_validate(self, modifier: Modifier) -> None:352 self._state._validate(modifier.value, self._intent)353 self.assertIn(modifier, self._intent.modifiers)354@ddt.ddt355class TestUntilAsState(unittest.TestCase):356 def setUp(self) -> None:357 self._state = UntilAsState(ModifierState())358 self._intent = Intent()359 @ddt.data(360 *((token, ModifierState) for token in {"and", ","}),361 ("until", The2State),362 ("as", DefaultState),363 )364 @ddt.unpack365 def test_run_success(self, token: str, successor_state: type) -> None:366 self.assertIsInstance(self._state.run(token, self._intent), successor_state)367 @ddt.data(("invalid", IllegalTransitionError))368 @ddt.unpack369 def test_run_error(self, token: str, exception: Type[Exception]) -> None:370 self.assertRaises(exception, self._state.run, token, self._intent)371@ddt.ddt372class TestThe2State(unittest.TestCase):373 def setUp(self) -> None:374 self._state = The2State()375 self._intent = Intent()376 @ddt.data(("the", IntervalState))377 @ddt.unpack378 def test_run_success(self, token: str, successor_state: type) -> None:379 self.assertIsInstance(self._state.run(token, self._intent), successor_state)380 @ddt.data(("invalid", IllegalTransitionError))381 @ddt.unpack382 def test_run_error(self, token: str, exception: Type[Exception]) -> None:383 self.assertRaises(exception, self._state.run, token, self._intent)384@ddt.ddt385class TestIntervalState(unittest.TestCase):386 def setUp(self) -> None:387 self._state = IntervalState()388 self._intent = Intent()389 @ddt.data(*((interval.value, CostsState) for interval in Interval))390 @ddt.unpack391 def test_run_success(self, token: str, successor_state: type) -> None:392 self.assertIsInstance(self._state.run(token, self._intent), successor_state)393 @ddt.data(("invalid", IllegalTransitionError))394 @ddt.unpack395 def test_run_error(self, token: str, exception: Type[Exception]) -> None:396 self.assertRaises(exception, self._state.run, token, self._intent)397 @ddt.data(*Interval)398 def test_validate(self, interval: Interval) -> None:399 self._state._validate(interval.value, self._intent)400 self.assertEqual(self._intent.interval, interval)401@ddt.ddt402class TestCostsState(unittest.TestCase):403 def setUp(self) -> None:404 self._state = CostsState()405 self._intent = Intent()406 @ddt.data(("costs", ReachState))407 @ddt.unpack408 def test_run_success(self, token: str, successor_state: type) -> None:409 self.assertIsInstance(self._state.run(token, self._intent), successor_state)410 @ddt.data(("invalid", IllegalTransitionError))411 @ddt.unpack412 def test_run_error(self, token: str, exception: Type[Exception]) -> None:413 self.assertRaises(exception, self._state.run, token, self._intent)414@ddt.ddt415class TestReachState(unittest.TestCase):416 def setUp(self) -> None:417 self._state = ReachState()418 self._intent = Intent()419 @ddt.data(("reach", CurrencyThresholdState))420 @ddt.unpack421 def test_run_success(self, token: str, successor_state: type) -> None:422 self.assertIsInstance(self._state.run(token, self._intent), successor_state)423 @ddt.data(("invalid", IllegalTransitionError))424 @ddt.unpack425 def test_run_error(self, token: str, exception: Type[Exception]) -> None:426 self.assertRaises(exception, self._state.run, token, self._intent)427@ddt.ddt428class TestCurrencyThresholdState(unittest.TestCase):429 def setUp(self) -> None:430 self._state = CurrencyThresholdState()431 self._intent = Intent()432 @ddt.data(433 *((currency.value, ThresholdState) for currency in Currency),434 ("47.2", PolicyState),435 )436 @ddt.unpack437 def test_run_success(self, token: str, successor_state: type) -> None:438 self.assertIsInstance(self._state.run(token, self._intent), successor_state)439 @ddt.data(("invalid", ValidationError))440 @ddt.unpack441 def test_run_error(self, token: str, exception: Type[Exception]) -> None:442 self.assertRaises(exception, self._state.run, token, self._intent)443 @ddt.data(*Currency)444 def test_validate(self, currency: Currency) -> None:445 self._state._validate(currency.value, self._intent)446 self.assertEqual(self._intent.currency, currency)447@ddt.ddt448class TestThresholdState(unittest.TestCase):449 def setUp(self) -> None:450 self._state = ThresholdState()451 self._intent = Intent()452 @ddt.data(("35.7", PolicyState))453 @ddt.unpack454 def test_run(self, token: str, successor_state: type) -> None:455 self.assertIsInstance(self._state.run(token, self._intent), successor_state)456 @ddt.data(("invalid", ValidationError))457 @ddt.unpack458 def test_run_error(self, token: str, exception: Type[Exception]) -> None:459 self.assertRaises(exception, self._state.run, token, self._intent)460 @ddt.data(15.7)461 def test_validate(self, threshold: float) -> None:462 self._state._validate(str(threshold), self._intent)463 self.assertEqual(self._intent.threshold, threshold)464 def test_validate_error(self) -> None:465 self.assertRaises(ValidationError, self._state._validate, "invalid", self._intent)466@ddt.ddt467class TestPolicyState(unittest.TestCase):468 def setUp(self) -> None:469 self._state = PolicyState()470 self._intent = Intent()471 @ddt.data("random")472 def test_run(self, token: str) -> None:473 self.assertRaises(IllegalTransitionError, self._state.run, token, self._intent)474@ddt.ddt475class TestDefaultState(unittest.TestCase):476 def setUp(self) -> None:477 self._state = DefaultState()478 self._intent = Intent()479 @ddt.data(("default", DefaultPolicyState))480 @ddt.unpack481 def test_run_success(self, token: str, successor_state: type) -> None:482 self.assertIsInstance(self._state.run(token, self._intent), successor_state)483 @ddt.data(("invalid", IllegalTransitionError))484 @ddt.unpack485 def test_run_error(self, token: str, exception: Type[Exception]) -> None:486 self.assertRaises(exception, self._state.run, token, self._intent)487 @ddt.data(*Timeframe)488 def test_validate(self, timeframe: Timeframe) -> None:489 self._intent.timeframe = timeframe490 self._state._validate("default", self._intent)491 self.assertIsNone(self._intent.timeframe)492 self.assertIsNone(self._intent.interval)493@ddt.ddt494class TestDefaultPolicyState(unittest.TestCase):495 def setUp(self) -> None:...

Full Screen

Full Screen

test_core.py

Source:test_core.py Github

copy

Full Screen

...25 ])26 result.stdout.no_re_match_line(r'.*\(filelock:\d+\)')27 result.stdout.no_re_match_line('.*coverage: platform.*')28 assert result.parseoutcomes() == {'failed': 6, 'passed': 1}29def test_run_success(makepyfile: Callable[[str], Path], pytester: pytest.Pytester) -> None:30 makepyfile("""31 def test_success() -> None:32 \"\"\"A test that will succeed.\"\"\"33 """)34 result = pytester.runpytest(*PYTEST_ARGS)35 result.stdout.re_match_lines_random(['.*coverage: platform.*'])36 assert result.parseoutcomes() == {'passed': 7}37 # Running the tests again skips file-based checks38 result = pytester.runpytest('-v', *PYTEST_ARGS)39 result.stdout.re_match_lines_random([40 r'.*SKIPPED test_run_success.py::bandit',41 r'.*SKIPPED test_run_success.py::isort',42 r'.*SKIPPED test_run_success.py::pylint',43 r'.*SKIPPED test_run_success.py::style',...

Full Screen

Full Screen

test_sorter.py

Source:test_sorter.py Github

copy

Full Screen

...34 sorter.run()35 sorted_frame_seq = sorter.get_sorted_frame_seq()36 L.warning("[UNITTEST][TestSorter][test_run_success] Sorted sequence: {}".format(sorted_frame_seq))37 self.assertIsNotNone(sorted_frame_seq)38 def test_run_success(self):39 sorter = Sorter(self.config)40 sorter.initialize(self.unsorted_frame_seq, cn_input_model=self.cn_input_model)41 sorter.run()42 sorted_frame_seq = sorter.get_sorted_frame_seq()43 L.warning("[UNITTEST][TestSorter][test_run_success] Sorted sequence: {}".format(sorted_frame_seq))44 self.assertIsNotNone(sorted_frame_seq)45 def test_run_failed(self):46 sorter = Sorter(self.config)47 sorter.initialize(self.unsorted_frame_seq, cn_input_model=self.invalid_cn_input_model)48 sorter.run()49 sorted_frame_seq = sorter.get_sorted_frame_seq()50 L.warning("[UNITTEST][TestSorter][test_run_failed] Sorted sequence: {}".format(sorted_frame_seq))51 self.assertIsNone(sorted_frame_seq)52if __name__ == '__main__':...

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