black: Test failures with Python 3.9.0b1
Describe the bug
With Python 3.9.0b1, there are test failures:
======================================================================
FAIL: test_beginning_backslash (tests.test_black.BlackTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib64/python3.9/unittest/mock.py", line 1337, in patched
return func(*newargs, **newkeywargs)
File ".../black/tests/test_black.py", line 768, in test_beginning_backslash
black.assert_equivalent(source, actual)
File ".../black/src/black/__init__.py", line 6050, in assert_equivalent
raise AssertionError(
AssertionError: INTERNAL ERROR: Black produced code that is not equivalent to the source. Please report a bug on https://github.com/psf/black/issues. This diff might be helpful:
--- src
+++ dst
@@ -1,17 +1,25 @@
Module(
body=
- Print(
- dest=
- None, # NoneType
- nl=
- True, # bool
- values=
- Constant(
- kind=
- None, # NoneType
- value=
- b'hello, world', # bytes
- ) # /Constant
- ) # /Print
+ Expr(
+ value=
+ Call(
+ args=
+ Constant(
+ kind=
+ None, # NoneType
+ value=
+ 'hello, world', # str
+ ) # /Constant
+ func=
+ Name(
+ ctx=
+ Load(
+ ) # /Load
+ id=
+ 'print', # str
+ ) # /Name
+ keywords=
+ ) # /Call
+ ) # /Expr
type_ignores=
) # /Module
======================================================================
FAIL: test_expression (tests.test_black.BlackTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../black/src/black/__init__.py", line 6029, in assert_equivalent
src_ast = parse_ast(src)
File ".../black/src/black/__init__.py", line 5948, in parse_ast
return ast27.parse(src)
File ".../black/__venv39__/lib64/python3.9/site-packages/typed_ast/ast27.py", line 50, in parse
return _ast27.parse(source, filename, mode)
File "<unknown>", line 1
...
^
SyntaxError: invalid syntax
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib64/python3.9/unittest/mock.py", line 1337, in patched
return func(*newargs, **newkeywargs)
File ".../black/tests/test_black.py", line 331, in test_expression
black.assert_equivalent(source, actual)
File ".../black/src/black/__init__.py", line 6031, in assert_equivalent
raise AssertionError(
AssertionError: cannot use --safe with this file; failed to parse source file. AST error message: invalid syntax (<unknown>, line 1)
======================================================================
FAIL: test_expression_diff (tests.test_black.BlackTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../black/tests/test_black.py", line 375, in test_expression_diff
self.assertEqual(result.exit_code, 0)
AssertionError: 123 != 0
======================================================================
FAIL: test_expression_diff_with_color (tests.test_black.BlackTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../black/tests/test_black.py", line 403, in test_expression_diff_with_color
self.assertIn("\033[1;37m", actual)
AssertionError: '\x1b[1;37m' not found in ''
======================================================================
FAIL: test_expression_ff (tests.test_black.BlackTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../black/src/black/__init__.py", line 6029, in assert_equivalent
src_ast = parse_ast(src)
File ".../black/src/black/__init__.py", line 5948, in parse_ast
return ast27.parse(src)
File "<unknown>", line 1
...
^
SyntaxError: invalid syntax
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".../black/tests/test_black.py", line 362, in test_expression_ff
black.assert_equivalent(source, actual)
File ".../black/src/black/__init__.py", line 6031, in assert_equivalent
raise AssertionError(
AssertionError: cannot use --safe with this file; failed to parse source file. AST error message: invalid syntax (<unknown>, line 1)
----------------------------------------------------------------------
Ran 140 tests in 35.840s
FAILED (failures=5)
To Reproduce Steps to reproduce the behavior:
git clone psf/black && cd blackpython3.9 -m venv __venv39__. __venv39__/bin/activatepip install -e '.[d]'python -m unittest
Expected behavior is that tests should pass.
Environment (please complete the following information):
- Version: master (now a2408b3cb23fe252b3674cee484d742496bb3411)
- OS and Python version: Linux (Fedora 32 x86_64) / Python 3.9.0b1
Does this bug also happen on master? yes (but also on the latest version)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (12 by maintainers)
Commits related to this issue
- expression tests: adjust starred expression for Python 3.9 (#1441) As discussed in #1441, Python 3.9's new parser will not parse `(*starred)` even using `compile()` with the `PyCF_ONLY_AST` flag (as ... — committed to AdamWill/black by AdamWill 4 years ago
- expression tests: adjust starred expression for Python 3.9 (#1441) As discussed in #1441, Python 3.9's new parser will not parse `(*starred)` even using `compile()` with the `PyCF_ONLY_AST` flag (as ... — committed to AdamWill/black by AdamWill 4 years ago
- expression tests: adjust starred expression for Python 3.9 (#1441) (#1477) As discussed in #1441, Python 3.9's new parser will not parse `(*starred)` even using `compile()` with the `PyCF_ONLY_AST` ... — committed to psf/black by AdamWill 4 years ago
- Merge pull request #14 from psf/master expression tests: adjust starred expression for Python 3.9 (#1441) (#1477) — committed to harenbrs/bleck by harenbrs 4 years ago
CPython 3.9 has been released and it’s in our testing matrix and is passing. Unless there are Fedora specific test failures (which seems highly unlikely) and someone speaks up, I’ll be closing this issue soon.