How to use _generate_tests method in Slash

Best Python code snippet using slash

tests.py

Source:tests.py Github

copy

Full Screen

...45 'subplots': [True]46 }47 def bar_test(self, **kwargs):48 self._iplot(self.df, **kwargs)49 _generate_tests(TestIPlot, bar_test, 'bar', options)50def bar_row_input_argument_tests():51 options = {52 'kind': ['bar', 'barh'],53 'barmode': ['stack', 'overlay', 'group'],54 'bargap': [0.1],55 'subplots': [True]56 }57 def bar_row_test(self, **kwargs):58 self._iplot(self.df.ix[1], **kwargs)59 _generate_tests(TestIPlot, bar_row_test, 'bar_row', options)60def histogram_input_argument_tests():61 options = {62 'barmode': ['stack'],63 'bins': [20],64 'orientation': ['h', 'v'],65 'histnorm': ['probability','percent','density'],66 'subplots': [True],67 'line_color':['blue','#fa0']68 }69 def histogram_test(self, **kwargs):70 self._iplot(self.df, kind='histogram', **kwargs)71 _generate_tests(TestIPlot, histogram_test, 'histogram', options)72def heatmap_input_argument_tests():73 options = {}74 def heatmap_test(self, **kwargs):75 self._iplot(self.df, kind='heatmap', **kwargs)76 df=cf.datagen.heatmap()77 df.index=cf.pd.period_range('1/1/2016',periods=5)78 self._iplot(df,kind='heatmap', **kwargs)79 # df.iplot(kind='heatmap')80 _generate_tests(TestIPlot, heatmap_test, 'heatmap', options)81def box_input_argument_tests():82 options = {}83 def box_test(self, **kwargs):84 self._iplot(self.df, kind='box', **kwargs)85 _generate_tests(TestIPlot, box_test, 'box', options)86def area_plot_input_argument_tests():87 options = {88 'fill': [True],89 'opacity': [1],90 'kind': ['area']91 }92 def area_test(self, **kwargs):93 self._iplot(self.df, **kwargs)94 _generate_tests(TestIPlot, area_test, 'area', options)95def scatter_plot_input_argument_tests():96 options = {97 'x': ['x'],98 'y': ['y'],99 'mode': ['markers'],100 'symbol': ['circle-dot'],101 'colors': [['orange', 'teal']],102 'size': [10]103 }104 def scatter_test(self, **kwargs):105 self._iplot(self.df, **kwargs)106 _generate_tests(TestIPlot, scatter_test, 'scatter', options)107def bubble_chart_argument_tests():108 options = {109 'x': ['x'], 'y': ['y'], 'size': ['c']110 }111 def bubble_test(self, **kwargs):112 self._iplot(self.df, **kwargs)113 _generate_tests(TestIPlot, bubble_test, 'bubble', options)114def subplot_input_argument_tests():115 options = {116 'shape': [(3, 1)],117 'shared_xaxes': [True],118 'vertical_spacing': [0.02],119 'fill': [True],120 'subplot_titles': [True],121 'legend': [False]122 }123 def subplot_test(self, **kwargs):124 self._iplot(self.df, subplots=True, **kwargs)125 _generate_tests(TestIPlot, subplot_test, 'subplots', options)126def shape_input_argument_tests():127 df = cf.datagen.lines(3, columns=['a', 'b', 'c'])128 options = {129 'hline': [130 [2, 4],131 [dict(y=-1, color='blue', width=3),132 dict(y=1, color='pink', dash='dash')]],133 'vline': [['2015-02-10']],134 'hspan': [[(-1, 1), (2, 5)]],135 'vspan': [{136 'x0': '2015-02-15', 'x1': '2015-03-15',137 'color': 'teal', 'fill': True, 'opacity': .4}]138 }139 def shape_tests(self, **kwargs):140 self._iplot(df, **kwargs)141 _generate_tests(TestIPlot, shape_tests, 'shape', options)142# colors143def color_normalize_tests():144 c=dict([(k.lower(),v.upper()) for k,v in list(cf.cnames.items())])145 d={}146 for k,v in list(c.items()):147 assert_equals(v,cf.normalize(k).upper())148 return 2149# technical analysis150def ta_tests():151 df=cf.datagen.lines(1,500)152 studies=['sma']153 options = {154 'periods' : [14]155 }156 def ta_tests(self, studies, **kwargs):157 for study in studies:158 self._ta(df, study, **kwargs)159 _generate_tests(TestIPlot, ta_tests, 'ta', options)160def quant_figure_tests():161 df=cf.datagen.ohlc()162 qf=cf.QuantFig(df)163 qf.add_sma()164 qf.add_atr()165 qf.add_bollinger_bands()166 return qf.figure()167def bestfit():168 df = cf.datagen.scatter()169 df['x'] = np.random.randint(1, 20, df.shape[0])170 df['y'] = df['x']171 df = df[['x', 'y']]172 options = {173 'kind': ['scatter'],174 'bestfit': [True],175 }176 def bestfit(self, **kwargs):177 self._iplot(df, **kwargs)178 _generate_tests(TestIPlot, bestfit, 'bestfit', options)179# test generators180def _generate_tests(test_class, test_func, test_name, options):181 from itertools import chain, combinations, product182 def powerset(iterable):183 "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"184 s = list(iterable)185 return chain.from_iterable(combinations(s, r)186 for r in range(len(s) + 1))187 key_value_tuple = {}188 for option, values in list(options.items()):189 key_value_tuple[option] = [(option, i) for i in values]190 for option_groups in powerset(key_value_tuple.values()):191 for input_kwargs in product(*option_groups):192 kwargs = {i[0]: i[1] for i in input_kwargs}193 setattr(194 test_class,...

Full Screen

Full Screen

twitter_preprocessor_tests.py

Source:twitter_preprocessor_tests.py Github

copy

Full Screen

1import unittest2from twitter_preprocessor import TwitterPreprocessor3from tests.test_cases_generator import TestCasesGenerator4class Tests(unittest.TestCase):5 def _generate_tests(self, module: str, method: str):6 for test_case in getattr(TestCasesGenerator, module):7 text = getattr(TwitterPreprocessor(text=test_case['case']), method)().text8 self.assertEqual(test_case['expected'], text)9 def test_remove_urls(self):10 self._generate_tests('urls', 'remove_urls')11 def test_remove_punctuation(self):12 self._generate_tests(module='punctuation', method='remove_punctuation')13 def test_remove_mentions(self):14 self._generate_tests(module='mentions', method='remove_mentions')15 def test_remove_hashtags(self):16 self._generate_tests(module='hashtags', method='remove_hashtags')17 def test_remove_twitter_reserved_words(self):18 self._generate_tests(module='twitter_reserved_words', method='remove_twitter_reserved_words')19 def test_remove_single_letter_words(self):20 self._generate_tests(module='single_letter_words', method='remove_single_letter_words')21 def test_remove_blank_spaces(self):22 self._generate_tests(module='blank_spaces', method='remove_blank_spaces')23 def test_remove_stopwords(self):24 self._generate_tests(module='stopwords', method='remove_stopwords')25if __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 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