@@ -201,8 +201,7 @@ def test_attributes_no_doctype(self, assign, expected, scope):
201201 ("type alias = int" , "alias: str" , "type alias = int" ),
202202 ],
203203 )
204- # @pytest.mark.parametrize("scope", ["module", "class", "nested class"])
205- @pytest .mark .parametrize ("scope" , ["module" ])
204+ @pytest .mark .parametrize ("scope" , ["module" , "class" , "nested class" ])
206205 def test_attributes_with_doctype (self , assign , doctype , expected , scope ):
207206 if scope == "module" :
208207 src = MODULE_ATTRIBUTE_TEMPLATE .format (assign = assign , doctype = doctype )
@@ -323,6 +322,7 @@ def test_preserved_type_comment(self):
323322 )
324323 expected = dedent (
325324 """
325+
326326 import untyped # type: ignore
327327 """
328328 )
@@ -360,32 +360,39 @@ def bar(x: str) -> None: ... # undocumented
360360 assert expected == result
361361
362362 def test_on_off_comment (self ):
363- source = """
364- class Foo:
365- '''
366- Parameters
367- ----------
368- a
369- b
370- c
371- d
372- '''
373- # docstub: off
374- a: int = None
375- b: str = ""
376- # docstub: on
377- c: int = None
378- b: str = ""
379- """
380- expected = """
381- class Foo:
363+ source = dedent (
364+ """
365+ class Foo:
366+ '''
367+ Parameters
368+ ----------
369+ a
370+ b
371+ c
372+ d
373+ '''
374+ # docstub: off
375+ a: int = None
376+ b: str = ""
377+ # docstub: on
378+ c: int = None
379+ b: str = ""
380+ """
381+ )
382+ expected = dedent (
383+ """
384+ class Foo:
382385
383- a: int = None
384- b: str = ""
386+ a: int = None
387+ b: str = ""
385388
386- c: int
387- b: str
388- """
389+ c: int
390+ b: str
391+ """
392+ )
389393 transformer = Py2StubTransformer ()
390394 result = transformer .python_to_stub (source )
395+ # Removing the comments leaves the whitespace from the indent,
396+ # remove these empty lines from the result too
397+ result = dedent (result )
391398 assert expected == result
0 commit comments