berkerpeksag / astor

Python AST read/write
https://pypi.org/project/astor/
BSD 3-Clause "New" or "Revised" License
810 stars 102 forks source link

tests.test_rtrip.RtripTestCase fails on Debian's Python 3.6 #119

Closed eLvErDe closed 5 years ago

eLvErDe commented 6 years ago
======================================================================
FAIL: test_convert_stdlib (tests.test_rtrip.RtripTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/acecile/packaging/python-astor/astor-0.7.1/tests/test_rtrip.py", line 24, in test_convert_stdlib
    self.assertEqual(result, [])
AssertionError: Lists differ: ['/usr/lib/python3.6/netrc.py'] != []

First list contains 1 additional elements.
First extra element 0:
'/usr/lib/python3.6/netrc.py'

- ['/usr/lib/python3.6/netrc.py']
+ []
berkerpeksag commented 6 years ago

I thought this was fixed in #89. See https://github.com/berkerpeksag/astor/issues/89#issuecomment-386336336 for more details. Could you please try to run astor.rtrip against https://github.com/python/cpython/blob/3.6/Lib/netrc.py?

eLvErDe commented 6 years ago
python3 -m astor.rtrip  /tmp/netrc.py 

Trashing tmp_rtrip
Converting /tmp/netrc.py
    calculating dump -- bad

Files failed to round-trip to AST:
    /tmp/netrc.py
berkerpeksag commented 6 years ago

Here's the generated code:

     def __repr__(self):
         """Dump the class data in the format of a .netrc file."""
-        rep = ""
+        rep = ''
         for host in self.hosts.keys():
             attrs = self.hosts[host]
-            rep += f"machine {host}\n\tlogin {attrs[0]}\n"
+            rep += f'machine {host}\n\tlogin {attrs[0]}\n            '
             if attrs[1]:
-                rep += f"\taccount {attrs[1]}\n"
-            rep += f"\tpassword {attrs[2]}\n"
+                rep += f'\taccount {attrs[1]}\n                '
+            rep += f'\tpassword {attrs[2]}\n            '
         for macro in self.macros.keys():
-            rep += f"macdef {macro}\n"
+            rep += f'macdef {macro}\n            '
             for line in self.macros[macro]:
                 rep += line
-            rep += "\n"
+            rep += '\n'
rickardcronholm commented 5 years ago

Is anybody working on this currently?

berkerpeksag commented 5 years ago

@rickardcronholm I don't work on this at the moment and I don't recall anybody has said they'd want to work on this as well. Feel free to submit a PR! :)

felixonmars commented 5 years ago

Hopefully this will be fixed by https://github.com/berkerpeksag/astor/pull/123