@@ -1899,6 +1899,7 @@ def test_dump_comments(self):
18991899 "# this is a header" ,
19001900 "#" ,
19011901 "# which may include empty comment lines" ,
1902+ " # weirdly indented lines" ,
19021903 '' ,
19031904 "# or flat out empty lines" ,
19041905 '' ,
@@ -1925,6 +1926,7 @@ def test_dump_comments(self):
19251926 "source_urls = [" ,
19261927 " # first possible source URL" ,
19271928 " 'https://example.com'," ,
1929+ "# annoying non-indented comment" ,
19281930 " 'https://anotherexample.com', # fallback URL" ,
19291931 "]" ,
19301932 '' ,
@@ -1933,7 +1935,8 @@ def test_dump_comments(self):
19331935 "# multi > 3" ,
19341936 "dependencies = [" ,
19351937 " # this dependency" ,
1936- " # has multiple lines above it" ,
1938+ "# has multiple lines above it" ,
1939+ " # some of which without proper indentation..." ,
19371940 " ('foo', '1.2.3'), # and an inline comment too" ,
19381941 " ('nocomment', '4.5')," ,
19391942 " # last dependency, I promise" ,
@@ -1961,6 +1964,7 @@ def test_dump_comments(self):
19611964
19621965 # check internal structure to keep track of comments
19631966 self .assertEqual (ec .parser ._formatter .comments ['above' ], {
1967+ " 'https://anotherexample.com'," : ['# annoying non-indented comment' ],
19641968 'dependencies' : [
19651969 '# this is a multiline comment above dependencies' ,
19661970 '# I said multiline' ,
@@ -1977,6 +1981,7 @@ def test_dump_comments(self):
19771981 '# this is a header' ,
19781982 '#' ,
19791983 '# which may include empty comment lines' ,
1984+ '# weirdly indented lines' ,
19801985 '' ,
19811986 '# or flat out empty lines' ,
19821987 '' ,
@@ -1988,7 +1993,8 @@ def test_dump_comments(self):
19881993 self .assertEqual (ec .parser ._formatter .comments ['iterabove' ], {
19891994 'dependencies' : {
19901995 " ('foo', '1.2.3')," : ['# this dependency' ,
1991- '# has multiple lines above it' ],
1996+ '# has multiple lines above it' ,
1997+ "# some of which without proper indentation..." ],
19921998 " ('last', '1.2.3')," : ['# last dependency, I promise' ],
19931999 ']' : ['# trailing comments in dependencies' , '# a bit weird, but it happens' ],
19942000 },
@@ -2029,6 +2035,7 @@ def test_dump_comments(self):
20292035 '# this is a header' ,
20302036 '#' ,
20312037 '# which may include empty comment lines' ,
2038+ '# weirdly indented lines' ,
20322039 '' ,
20332040 '# or flat out empty lines' ,
20342041 '' ,
@@ -2081,6 +2088,7 @@ def test_dump_comments(self):
20812088 r'' ,
20822089 r" # this dependency" ,
20832090 r" # has multiple lines above it" ,
2091+ r" # some of which without proper indentation\.\.\." ,
20842092 r" \('foo', '1\.2\.3'\), # and an inline comment too" ,
20852093 ]),
20862094 '\n ' .join ([
@@ -2103,6 +2111,11 @@ def test_dump_comments(self):
21032111 r" # first possible source URL" ,
21042112 r" 'https://example\.com'," ,
21052113 ]),
2114+ '\n ' .join ([
2115+ '' ,
2116+ r" # annoying non-indented comment" ,
2117+ r" 'https://anotherexample\.com', # fallback URL" ,
2118+ ]),
21062119 ]
21072120 for pattern in patterns :
21082121 regex = re .compile (pattern , re .M )
0 commit comments