Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit test failure python 3.6.5 #25

Closed
sclarkson opened this issue May 1, 2018 · 7 comments
Closed

unit test failure python 3.6.5 #25

sclarkson opened this issue May 1, 2018 · 7 comments

Comments

@sclarkson
Copy link

python setup.py test

======================================================================
ERROR: test_joined_str (tests.test_unparse.UnparseTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sclarkson/astunparse/tests/common.py", line 296, in test_joined_str
    self.check_roundtrip('f"{key:4}={value!s}"')
  File "/home/sclarkson/astunparse/tests/test_unparse.py", line 19, in check_roundtrip
    ast2 = compile(code2, filename, mode, ast.PyCF_ONLY_AST)
  File "internal", line 2
    f'''{key:f'''4'''}={value!s}'''
                 ^
SyntaxError: invalid syntax

----------------------------------------------------------------------

This is on Arch Linux

python --version
Python 3.6.5

@eLvErDe
Copy link

eLvErDe commented Aug 28, 2018

Confirmed on Python 3.6.6 (Debian Buster), I'm actually wondering if this syntax isn't python >= 3.7...

@eLvErDe
Copy link

eLvErDe commented Aug 28, 2018

--- astunparse-1.5.0.orig/tests/common.py
+++ astunparse-1.5.0/tests/common.py
@@ -288,7 +288,7 @@ class AstunparseCommonTestCase:
     def test_bytes(self):
         self.check_roundtrip("b'123'")

-    @unittest.skipIf(sys.version_info < (3, 6), "Not supported < 3.6")
+    @unittest.skipIf(sys.version_info < (3, 7), "Not supported < 3.7")
     def test_joined_str(self):
         self.check_roundtrip('f"{key}={value!s}"')
         self.check_roundtrip('f"{key}={value!r}"')

@mbdevpl
Copy link
Contributor

mbdevpl commented Aug 28, 2018

The f-strings are certainly a 3.6 syntax.

That f'''{key:f'''4'''}={value!s}''' should be f'{key:f4}={value!s}'(or something like that) instead.

I think that error might be occurring because implementation of unparsing of f-strings in astunparse is very simplistic. I think I did the first f-string unparsing implementation for argunparse. Maybe it's still around, and in such case I guess I'm the culprit here ;) We all could use a proper f-string unparser...

But why does this test pass on Travis where python version is 3.6.3 and not on 3.6.5 or 3.6.6? I have no idea...

@sclarkson
Copy link
Author

I still get this (and one more f-string error) on Python 3.7.0

@simonpercivall
Copy link
Owner

This is now (should now) be fixed in v1.6.0. (Please reopen if I missed something.)

@eLvErDe
Copy link

eLvErDe commented Apr 23, 2019

Hello,

The patch still applies on 1.6.2 so I guess it is not fixed.
Btw, I have no idea how to re-open a GitHub ticket...

Regards,

@sclarkson
Copy link
Author

Retested and v1.6.2 tests still work on Python 3.7.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants