1- import unittest
1+ from unittest import TestCase , main
22
33from getgauge .messages .messages_pb2 import Message
4- from getgauge .python import Messages , DataStore , DataStoreFactory , Table , Specification , Scenario , Step , \
5- ExecutionContext , \
6- create_execution_context_from
74from getgauge .registry import registry , _MessagesStore
5+ from getgauge .python import (Messages , DataStore , DataStoreFactory , Table ,
6+ Specification , Scenario , Step , ExecutionContext ,
7+ create_execution_context_from )
88
99registry .clear ()
1010
1111
12- class MessagesTests (unittest . TestCase ):
12+ class MessagesTests (TestCase ):
1313 def test_pending_messages (self ):
1414 messages = ['HAHAHAH' , 'HAHAHAH1' , 'HAHAHAH2' , 'HAHAHAH3' ]
1515 for message in messages :
@@ -45,10 +45,14 @@ def test_pending_messages_gives_only_those_messages_which_are_not_reported(self)
4545 self .assertEqual (messages , pending_messages )
4646
4747
48- class DataStoreTests (unittest . TestCase ):
48+ class DataStoreTests (TestCase ):
4949 def test_data_store (self ):
5050 store = DataStore ()
51- values = {'key' : 'HAHAHAH' , 'key1' : 'HAHAHAH1' , 'key2' : 'HAHAHAH2' , 'key3' : 'HAHAHAH3' }
51+ values = {'key' : 'HAHAHAH' ,
52+ 'key1' : 'HAHAHAH1' ,
53+ 'key2' : 'HAHAHAH2' ,
54+ 'key3' : 'HAHAHAH3' }
55+
5256 for value in values :
5357 store .put (value , value )
5458
@@ -60,7 +64,11 @@ def test_data_store(self):
6064
6165 def test_data_store_clear (self ):
6266 store = DataStore ()
63- values = {'key' : 'HAHAHAH' , 'key1' : 'HAHAHAH1' , 'key2' : 'HAHAHAH2' , 'key3' : 'HAHAHAH3' }
67+ values = {'key' : 'HAHAHAH' ,
68+ 'key1' : 'HAHAHAH1' ,
69+ 'key2' : 'HAHAHAH2' ,
70+ 'key3' : 'HAHAHAH3' }
71+
6472 for value in values :
6573 store .put (value , value )
6674
@@ -92,7 +100,7 @@ def test_data_store_equality(self):
92100 self .assertNotEqual (store , store1 )
93101
94102
95- class DataStoreFactoryTests (unittest . TestCase ):
103+ class DataStoreFactoryTests (TestCase ):
96104 def test_data_store_factory (self ):
97105 scenario_data_store = DataStoreFactory .scenario_data_store ()
98106 spec_data_store = DataStoreFactory .spec_data_store ()
@@ -116,7 +124,7 @@ def __init__(self, cells):
116124 self .cells = cells
117125
118126
119- class TableTests (unittest . TestCase ):
127+ class TableTests (TestCase ):
120128 def test_Table (self ):
121129 headers = ['Product' , 'Description' ]
122130 rows = [{'cells' : ['Gauge' , 'Test automation with ease' ]},
@@ -134,10 +142,15 @@ def test_Table(self):
134142
135143 self .assertEqual (headers , table .headers )
136144 self .assertEqual (expected_rows , table .rows )
137- self .assertEqual (expected_column_1 , table .get_column_values_with_index (1 ))
138- self .assertEqual (expected_column_2 , table .get_column_values_with_index (2 ))
139- self .assertEqual (expected_column_1 , table .get_column_values_with_name (headers [0 ]))
140- self .assertEqual (expected_column_2 , table .get_column_values_with_name (headers [1 ]))
145+ self .assertEqual (expected_column_1 ,
146+ table .get_column_values_with_index (1 ))
147+ self .assertEqual (expected_column_2 ,
148+ table .get_column_values_with_index (2 ))
149+ self .assertEqual (expected_column_1 ,
150+ table .get_column_values_with_name (headers [0 ]))
151+ self .assertEqual (expected_column_2 ,
152+ table .get_column_values_with_name (headers [1 ]))
153+
141154 for row in expected_rows :
142155 self .assertEqual (row , table .get_row (expected_rows .index (row ) + 1 ))
143156
@@ -212,7 +225,7 @@ def test_Table__str__without_rows(self):
212225|----|-----------|""" )
213226
214227
215- class SpecificationTests (unittest . TestCase ):
228+ class SpecificationTests (TestCase ):
216229 def test_Specification (self ):
217230 name = 'NAME'
218231 file_name = 'FILE_NAME'
@@ -234,7 +247,7 @@ def test_Specification_equality(self):
234247 self .assertEqual (specification , specification1 )
235248
236249
237- class ScenarioTests (unittest . TestCase ):
250+ class ScenarioTests (TestCase ):
238251 def test_Scenario (self ):
239252 name = 'NAME3'
240253 tags = ['TAGS' ]
@@ -253,7 +266,7 @@ def test_Scenario_equality(self):
253266 self .assertEqual (scenario , scenario1 )
254267
255268
256- class StepTests (unittest . TestCase ):
269+ class StepTests (TestCase ):
257270 def test_Step (self ):
258271 name = 'NAME1'
259272 step = Step (name , False )
@@ -269,7 +282,7 @@ def test_Step_equality(self):
269282 self .assertEqual (step , step1 )
270283
271284
272- class ExecutionContextTests (unittest . TestCase ):
285+ class ExecutionContextTests (TestCase ):
273286 def test_ExecutionContextTests (self ):
274287 name = 'NAME'
275288 file_name = 'FILE_NAME'
@@ -298,14 +311,25 @@ def test_ExecutionContextTests_equality(self):
298311
299312 def test_create_execution_context_from (self ):
300313 message = Message ()
301- spec_name , spec_file_name , scenario_name , step_name = 'SPEC_NAME' , 'SPEC_FILE_NAME' , 'SCENARIO_NAME' , 'STEP_NAME'
302- message .executionStartingRequest .currentExecutionInfo .currentSpec .name = spec_name
303- message .executionStartingRequest .currentExecutionInfo .currentSpec .fileName = spec_file_name
304- message .executionStartingRequest .currentExecutionInfo .currentSpec .isFailed = True
305- message .executionStartingRequest .currentExecutionInfo .currentScenario .name = scenario_name
306- message .executionStartingRequest .currentExecutionInfo .currentScenario .isFailed = False
307- message .executionStartingRequest .currentExecutionInfo .currentStep .step .actualStepText = step_name
308- message .executionStartingRequest .currentExecutionInfo .currentStep .isFailed = True
314+ spec_name = 'SPEC_NAME'
315+ spec_file_name = 'SPEC_FILE_NAME'
316+ scenario_name = 'SCENARIO_NAME'
317+ step_name = 'STEP_NAME'
318+
319+ message .executionStartingRequest .\
320+ currentExecutionInfo .currentSpec .name = spec_name
321+ message .executionStartingRequest .\
322+ currentExecutionInfo .currentSpec .fileName = spec_file_name
323+ message .executionStartingRequest .\
324+ currentExecutionInfo .currentSpec .isFailed = True
325+ message .executionStartingRequest .\
326+ currentExecutionInfo .currentScenario .name = scenario_name
327+ message .executionStartingRequest .\
328+ currentExecutionInfo .currentScenario .isFailed = False
329+ message .executionStartingRequest .\
330+ currentExecutionInfo .currentStep .step .actualStepText = step_name
331+ message .executionStartingRequest .\
332+ currentExecutionInfo .currentStep .isFailed = True
309333
310334 specification = Specification (spec_name , spec_file_name , True , [])
311335 scenario = Scenario (scenario_name , False , [])
@@ -318,7 +342,7 @@ def test_create_execution_context_from(self):
318342 self .assertEqual (expected_execution_context , context )
319343
320344
321- class DecoratorTests (unittest . TestCase ):
345+ class DecoratorTests (TestCase ):
322346 def setUp (self ):
323347 from tests .test_data import impl_stubs
324348 impl_stubs .step1 ()
@@ -332,8 +356,10 @@ def test_continue_on_failure(self):
332356 step1 = registry .get_info_for ('Step 1' ).impl
333357 step2 = registry .get_info_for ('Step 2' ).impl
334358
335- self .assertEqual (registry .is_continue_on_failure (step1 , RuntimeError ()), False )
336- self .assertEqual (registry .is_continue_on_failure (step2 , RuntimeError ()), True )
359+ self .assertEqual (
360+ registry .is_continue_on_failure (step1 , RuntimeError ()), False )
361+ self .assertEqual (
362+ registry .is_continue_on_failure (step2 , RuntimeError ()), True )
337363
338364 def test_before_step_decorator (self ):
339365 funcs = registry .before_step ()
@@ -382,4 +408,4 @@ def test_screenshot_decorator(self):
382408
383409
384410if __name__ == '__main__' :
385- unittest . main ()
411+ main ()
0 commit comments