Best Python code snippet using autotest_python
test_trade_data.py
Source: test_trade_data.py
...16 self.price = 20017 self.volume = 10018 pass19 def test_get_trade_data_all_symbols_found(self, mock_function):20 self._set_return_value(mock_function, ETH)21 data = TradeData.get_data_for_all_symbols()22 self.assertTrue(TradeData.get_current_trade_data(data, ETH, TradeData.PRICE), self.price)23 self.assertTrue(TradeData.get_current_trade_data(data, ETH, TradeData.VOLUME), self.volume)24 25 def test_get_trade_data_all_symbols_not_found(self, mock_function):26 self._set_return_value(mock_function, XXX)27 self.assertIsNone(TradeData.get_current_trade_data(28 TradeData.get_data_for_all_symbols(), XXX, TradeData.PRICE), self.price)29 def test_get_number_of_rows_not_empty(self, mock_function):30 self._set_return_value(mock_function, ETH)31 data = TradeData.get_data_for_all_symbols()32 data = data.append(TradeData.get_data_for_all_symbols())33 self.assertTrue(TradeData.get_number_of_rows(data, ETH) == 2)34 35 def test_get_number_of_rows_empty(self, mock_function):36 self._set_return_value(mock_function, ETH)37 self.assertTrue(TradeData.get_number_of_rows(TradeData.get_data_for_all_symbols(), LTC) == 0)38 def test_get_penultimate_trade_data(self, mock_function):39 self._set_return_value(mock_function, ETH)40 self.price = 100041 self.volume = 200042 data = TradeData.get_data_for_all_symbols()43 self.price = 200044 self.volume = 400045 data = data.append(TradeData.get_data_for_all_symbols())46 penultimate_price = self.price47 penultimate_volume = self.volume48 self.price = 2000049 self.volume = 4000050 data = data.append(TradeData.get_data_for_all_symbols())51 self.assertTrue(TradeData.get_penultimate_trade_data(data, ETH, TradeData.VOLUME), 52 penultimate_volume)53 self.assertTrue(TradeData.get_penultimate_trade_data(data, ETH, TradeData.PRICE), 54 penultimate_price)55 def test_get_penultimate_trade_data(self, mock_function):56 self._set_return_value(mock_function, ETH)57 self.price = 100058 self.volume = 200059 data = TradeData.get_data_for_all_symbols()60 self.price = 200061 self.volume = 400062 data = data.append(TradeData.get_data_for_all_symbols())63 n_price = self.price64 n_volume = self.volume65 self.price = 2000066 self.volume = 4000067 data = data.append(TradeData.get_data_for_all_symbols())68 self.price = 10000069 self.volume = 200000070 data = data.append(TradeData.get_data_for_all_symbols())71 self.assertTrue(TradeData.get_current_minus_n_trade_data(data, ETH, TradeData.VOLUME, 3), 72 n_volume)73 self.assertTrue(TradeData.get_current_minus_n_trade_data(data, ETH, TradeData.PRICE, 3), 74 n_price)75 def _set_return_value(self, _mock_function, ticker):76 """ This private method sets the return value of the mock function that is called repeatedly77 for every test method78 Args:79 mock_function(MagicMock): the mock function80 ticker_symbol(str): the ticker to be acted upon81 """82 _mock_function.return_value = [{TradeClient().VOLUME: self.volume, 83 TradeClient().PRICE: self.price, ...
sharedmock.py
Source: sharedmock.py
...9from pprint import pformat10class SharedMockObj:11 def __init__(self):12 self.call_parameters = []13 self._set_return_value(None)14 def __call__(self, *args, **kwargs):15 self.call_parameters.append({'args': args, 'kwargs': kwargs})16 return self.return_value17 def _get_call_parameters(self):18 return self.call_parameters19 def _set_return_value(self, value):20 self.return_value = value21 def call_count(self):22 return len(self.call_parameters)23class SharedMockProxy(BaseProxy):24 _exposed_ = ['__call__',25 '_get_call_parameters',26 '_set_return_value',27 '_set_return_value_empty_dict',28 'assert_has_calls',29 'call_count'30 ]31 def __setattr__(self, name, value):32 if name == 'return_value':33 self._callmethod('_set_return_value', args=(value,))...
mock.py
Source: mock.py
...3from sharedmock.asserters import assert_calls_equal, assert_calls_equal_unsorted4class SharedMockObj:5 def __init__(self):6 self.call_parameters = []7 self._set_return_value(None)8 def __call__(self, *args, **kwargs):9 self.call_parameters.append({'args': args, 'kwargs': kwargs})10 return self.return_value11 def _get_call_parameters(self):12 return self.call_parameters13 def _set_return_value(self, value):14 self.return_value = value15 def call_count(self):16 return len(self.call_parameters)17class SharedMockProxy(BaseProxy):18 _exposed_ = ['__call__',19 '_get_call_parameters',20 '_set_return_value',21 '_set_return_value_empty_dict',22 'assert_has_calls',23 'call_count'24 ]25 def __setattr__(self, name, value):26 if name == 'return_value':27 self._callmethod('_set_return_value', args=(value,))...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
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!!