@@ -34,8 +34,6 @@ def test_docstring():
3434 - from 'activedescendant' to 'owns' - relationships between elements other than parent/child/sibling.
3535 '''""" )
3636 actual = docstring (description )
37- print ('EXPECTED:' , expected )
38- print ('ACTUAL:' , actual )
3937 assert expected == actual
4038
4139
@@ -62,8 +60,6 @@ def __repr__(self):
6260
6361 type = CdpType .from_json (json_type )
6462 actual = type .generate_code ()
65- print ('EXPECTED:' , expected )
66- print ('ACTUAL:' , actual )
6763 assert expected == actual
6864
6965
@@ -93,8 +89,6 @@ def __repr__(self):
9389
9490 type = CdpType .from_json (json_type )
9591 actual = type .generate_code ()
96- print ('EXPECTED:' , expected )
97- print ('ACTUAL:' , actual )
9892 assert expected == actual
9993
10094
@@ -133,8 +127,6 @@ def from_json(cls, json: str) -> AXValueSourceType:
133127
134128 type = CdpType .from_json (json_type )
135129 actual = type .generate_code ()
136- print ('EXPECTED:' , expected )
137- print ('ACTUAL:' , actual )
138130 assert expected == actual
139131
140132
@@ -182,7 +174,7 @@ class AXValue:
182174 A single computed AX property.
183175 '''
184176 #: The type of this value.
185- type : AXValueType
177+ type_ : AXValueType
186178
187179 #: The computed value of this property.
188180 value: typing.Optional[typing.Any] = None
@@ -195,7 +187,7 @@ class AXValue:
195187
196188 def to_json(self) -> T_JSON_DICT:
197189 json: T_JSON_DICT = dict()
198- json['type'] = self.type .to_json()
190+ json['type'] = self.type_ .to_json()
199191 if self.value is not None:
200192 json['value'] = self.value
201193 if self.related_nodes is not None:
@@ -207,16 +199,14 @@ def to_json(self) -> T_JSON_DICT:
207199 @classmethod
208200 def from_json(cls, json: T_JSON_DICT) -> AXValue:
209201 return cls(
210- type =AXValueType.from_json(json['type']),
202+ type_ =AXValueType.from_json(json['type']),
211203 value=json['value'] if 'value' in json else None,
212204 related_nodes=[AXRelatedNode.from_json(i) for i in json['relatedNodes']] if 'relatedNodes' in json else None,
213205 sources=[AXValueSource.from_json(i) for i in json['sources']] if 'sources' in json else None,
214206 )""" )
215207
216208 type = CdpType .from_json (json_type )
217209 actual = type .generate_code ()
218- print ('EXPECTED:' , expected )
219- print ('ACTUAL:' , actual )
220210 assert expected == actual
221211
222212
@@ -297,8 +287,6 @@ def get_partial_ax_tree(
297287
298288 cmd = CdpCommand .from_json (json_cmd , 'Accessibility' )
299289 actual = cmd .generate_code ()
300- print ('EXPECTED:' , expected )
301- print ('ACTUAL:' , actual )
302290 assert expected == actual
303291
304292
@@ -319,8 +307,6 @@ def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
319307
320308 cmd = CdpCommand .from_json (json_cmd , 'Accessibility' )
321309 actual = cmd .generate_code ()
322- print ('EXPECTED:' , expected )
323- print ('ACTUAL:' , actual )
324310 assert expected == actual
325311
326312
@@ -345,16 +331,16 @@ def test_cdp_command_return_primitive():
345331 }
346332 expected = dedent ("""\
347333 def get_current_time(
348- id : str
334+ id_ : str
349335 ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,float]:
350336 '''
351337 Returns the current time of the an animation.
352338
353- :param id : Id of animation.
339+ :param id_ : Id of animation.
354340 :returns: Current time of the page.
355341 '''
356342 params: T_JSON_DICT = dict()
357- params['id'] = id
343+ params['id'] = id_
358344 cmd_dict: T_JSON_DICT = {
359345 'method': 'Animation.getCurrentTime',
360346 'params': params,
@@ -364,8 +350,6 @@ def get_current_time(
364350
365351 cmd = CdpCommand .from_json (json_cmd , 'Animation' )
366352 actual = cmd .generate_code ()
367- print ('EXPECTED:' , expected )
368- print ('ACTUAL:' , actual )
369353 assert expected == actual
370354
371355
@@ -401,8 +385,6 @@ def get_browser_command_line() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typin
401385
402386 cmd = CdpCommand .from_json (json_cmd , 'Browser' )
403387 actual = cmd .generate_code ()
404- print ('EXPECTED:' , expected )
405- print ('ACTUAL:' , actual )
406388 assert expected == actual
407389
408390
@@ -440,8 +422,6 @@ def release_animations(
440422
441423 cmd = CdpCommand .from_json (json_cmd , 'Animation' )
442424 actual = cmd .generate_code ()
443- print ('EXPECTED:' , expected )
444- print ('ACTUAL:' , actual )
445425 assert expected == actual
446426
447427
@@ -485,8 +465,6 @@ def resolve_animation(
485465
486466 cmd = CdpCommand .from_json (json_cmd , 'Animation' )
487467 actual = cmd .generate_code ()
488- print ('EXPECTED:' , expected )
489- print ('ACTUAL:' , actual )
490468 assert expected == actual
491469
492470
@@ -582,8 +560,6 @@ def get_encoded_response(
582560
583561 cmd = CdpCommand .from_json (json_cmd , 'Audits' )
584562 actual = cmd .generate_code ()
585- print ('EXPECTED:' , expected )
586- print ('ACTUAL:' , actual )
587563 assert expected == actual
588564
589565
@@ -638,8 +614,6 @@ def grant_permissions(
638614
639615 cmd = CdpCommand .from_json (json_cmd , 'Browser' )
640616 actual = cmd .generate_code ()
641- print ('EXPECTED:' , expected )
642- print ('ACTUAL:' , actual )
643617 assert expected == actual
644618
645619
@@ -677,8 +651,6 @@ def from_json(cls, json: T_JSON_DICT) -> RecordingStateChanged:
677651
678652 cmd = CdpEvent .from_json (json_event , 'BackgroundService' )
679653 actual = cmd .generate_code ()
680- print ('EXPECTED:' , expected )
681- print ('ACTUAL:' , actual )
682654 assert expected == actual
683655
684656
@@ -740,8 +712,6 @@ def from_json(cls, json: T_JSON_DICT) -> WindowOpen:
740712
741713 cmd = CdpEvent .from_json (json_event , 'Page' )
742714 actual = cmd .generate_code ()
743- print ('EXPECTED:' , expected )
744- print ('ACTUAL:' , actual )
745715 assert expected == actual
746716
747717
@@ -846,6 +816,30 @@ def test_cdp_domain_imports():
846816
847817 domain = CdpDomain .from_json (json_domain )
848818 actual = domain .generate_imports ()
849- print ('EXPECTED:' , expected )
850- print ('ACTUAL:' , actual )
851819 assert expected == actual
820+
821+
822+ def test_domain_shadows_builtin ():
823+ ''' If a domain name shadows a Python builtin, it should have an underscore
824+ appended to the module name. '''
825+ input_domain = {
826+ "domain" : "Input" ,
827+ "types" : [],
828+ "commands" : [],
829+ "events" : [],
830+ }
831+ domain = CdpDomain .from_json (input_domain )
832+ assert domain .module == 'input_'
833+
834+
835+ def test_domain_shadows_builtin ():
836+ ''' If a domain name shadows a Python builtin, it should have an underscore
837+ appended to the module name. '''
838+ input_domain = {
839+ "domain" : "Input" ,
840+ "types" : [],
841+ "commands" : [],
842+ "events" : [],
843+ }
844+ domain = CdpDomain .from_json (input_domain )
845+ assert domain .module == 'input_'
0 commit comments