Best Python code snippet using autotest_python
sayshell.py
Source:sayshell.py
...34 def volume(self, volume):35 if not volume:36 return self._info.format('Volume', self._nums, self._sets['absolute_volume'])37 else:38 return self._set_set('absolute_volume', volume)39 def rate(self, rate):40 if not rate:41 return self._info.format('Rate', self._nums, self._sets['absolute_rate'])42 else:43 return self._set_set('absolute_rate', rate)44 def pitch(self, pitch):45 if not pitch:46 return self._info.format('Pitch', self._nums, self._sets['absolute_pitch'])47 else:48 return self._set_set('absolute_pitch', pitch)49 def voice(self, voice):50 if not voice:51 return self._info.format('Voice', ', '.join(self.tts.voices), ', '.join(self._sets['voice']))52 else:53 if isinstance(voice, str):54 voice = [voice]55 voice = voice[:2]56 return self._set_set('voice', voice)57 def _set_set(self, param, value):58 if self._sets[param] == value:59 return 'unchanged'60 if param == 'voice':61 return self._set_voice(value)62 else:63 n_value = _prepare_set(value)64 if n_value is None:65 return 'bad value: {}'.format(value)66 self._sets[param] = str(n_value)67 self.tts.set_params(**{param: _normalize_set(n_value)})68 return 'success'69 def _set_voice(self, voice):70 for target in voice:71 if target not in self.tts.voices:...
control_data_unittest.py
Source:control_data_unittest.py
...75 self.assertRaises(ValueError, cd._set_int, 'foo', '')76 self.assertRaises(TypeError, cd._set_int, 'foo', None)77 def test_set(self):78 cd = ControlData({}, 'filename')79 cd._set_set('foo', 'a')80 self.assertEquals(cd.foo, set(['a']))81 cd._set_set('foo', 'a,b,c')82 self.assertEquals(cd.foo, set(['a', 'b', 'c']))83 cd._set_set('foo', ' a , b , c ')84 self.assertEquals(cd.foo, set(['a', 'b', 'c']))85 cd._set_set('foo', None)86 self.assertEquals(cd.foo, set(['None']))87 def test_string(self):88 cd = ControlData({}, 'filename')89 cd._set_string('foo', 'a')90 self.assertEquals(cd.foo, 'a')91 cd._set_string('foo', 'b')92 self.assertEquals(cd.foo, 'b')93 cd._set_string('foo', 'B')94 self.assertEquals(cd.foo, 'B')95 cd._set_string('foo', 1)96 self.assertEquals(cd.foo, '1')97 cd._set_string('foo', None)98 self.assertEquals(cd.foo, 'None')99 cd._set_string('foo', [])...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!