1.4: pytest is failing
See original GitHub issueLooks like it some issue with test suite
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/autoflake-1.4
collected 119 items
test_autoflake.py ..........F..FF....FF.....F......................F.............FFF.F..............F.......F...FF.F......F.F............ [100%]
================================================================================= FAILURES =================================================================================
________________________________________________________________________ UnitTests.test_filter_code ________________________________________________________________________
self = <test_autoflake.UnitTests testMethod=test_filter_code>
def test_filter_code(self):
> self.assertEqual(
"""\
import os
pass
os.foo()
""",
''.join(autoflake.filter_code("""\
import os
import re
os.foo()
""")))
E AssertionError: 'import os\npass\nos.foo()\n' != 'import os\nimport re\nos.foo()\n'
E import os
E - pass
E + import re
E os.foo()
test_autoflake.py:157: AssertionError
____________________________________________________________ UnitTests.test_filter_code_multiline_from_imports _____________________________________________________________
self = <test_autoflake.UnitTests testMethod=test_filter_code_multiline_from_imports>
def test_filter_code_multiline_from_imports(self):
> self.assertEqual(
r"""\
import os
pass
from os.path import (
join,
)
join('a', 'b')
pass
os.foo()
from os.path import \
isdir
isdir('42')
""",
''.join(autoflake.filter_code(r"""\
import os
import re
from os.path import (
exists,
join,
)
join('a', 'b')
from os.path import \
abspath, basename, \
commonpath
os.foo()
from os.path import \
isfile \
, isdir
isdir('42')
""")))
E AssertionError: "\\\nimport os\npass\nfrom os.path import (\n join,\n)[78 chars]')\n" != "\\\nimport os\nimport re\nfrom os.path import (\n joi[83 chars]')\n"
E \
E import os
E - pass
E + import re
E from os.path import (
E join,
E )
E join('a', 'b')
E pass
E os.foo()
E from os.path import \
E isdir
E isdir('42')
test_autoflake.py:443: AssertionError
_______________________________________________________________ UnitTests.test_filter_code_multiline_imports _______________________________________________________________
self = <test_autoflake.UnitTests testMethod=test_filter_code_multiline_imports>
def test_filter_code_multiline_imports(self):
> self.assertEqual(
r"""\
import os
pass
import os
os.foo()
""",
''.join(autoflake.filter_code(r"""\
import os
import re
import os, \
math, subprocess
os.foo()
""")))
E AssertionError: '\\\nimport os\npass\nimport os\nos.foo()\n' != '\\\nimport os\nimport re\nimport os, \\\n subprocess\nos.foo()\n'
E \
E import os
E - pass
E + import re
E - import os
E + import os, \
E ? +++
E + subprocess
E os.foo()
test_autoflake.py:427: AssertionError
______________________________________________________ UnitTests.test_filter_code_should_ignore_non_standard_library _______________________________________________________
self = <test_autoflake.UnitTests testMethod=test_filter_code_should_ignore_non_standard_library>
def test_filter_code_should_ignore_non_standard_library(self):
> self.assertEqual(
"""\
import os
import my_own_module
pass
from my_package import another_module
from my_package import subprocess
from my_blah.my_blah_blah import blah
os.foo()
""",
''.join(autoflake.filter_code("""\
import os
import my_own_module
import re
from my_package import another_module
from my_package import subprocess
from my_blah.my_blah_blah import blah
os.foo()
""")))
E AssertionError: 'impo[24 chars]ule\npass\nfrom my_package import another_modu[84 chars]()\n' != 'impo[24 chars]ule\nimport re\nfrom my_package import another[89 chars]()\n'
E import os
E import my_own_module
E - pass
E + import re
E from my_package import another_module
E from my_package import subprocess
E from my_blah.my_blah_blah import blah
E os.foo()
test_autoflake.py:491: AssertionError
___________________________________________________________ UnitTests.test_filter_code_should_ignore_semicolons ____________________________________________________________
self = <test_autoflake.UnitTests testMethod=test_filter_code_should_ignore_semicolons>
def test_filter_code_should_ignore_semicolons(self):
> self.assertEqual(
r"""\
import os
pass
import os; import math, subprocess
os.foo()
""",
''.join(autoflake.filter_code(r"""\
import os
import re
import os; import math, subprocess
os.foo()
""")))
E AssertionError: '\\\nimport os\npass\nimport os; import math, subprocess\nos.foo()\n' != '\\\nimport os\nimport re\nimport os; import math, subprocess\nos.foo()\n'
E \
E import os
E - pass
E + import re
E import os; import math, subprocess
E os.foo()
test_autoflake.py:476: AssertionError
_____________________________________________________________ UnitTests.test_filter_code_with_indented_import ______________________________________________________________
self = <test_autoflake.UnitTests testMethod=test_filter_code_with_indented_import>
def test_filter_code_with_indented_import(self):
> self.assertEqual(
"""\
import os
if True:
pass
os.foo()
""",
''.join(autoflake.filter_code("""\
import os
if True:
import re
os.foo()
""")))
E AssertionError: 'import os\nif True:\n pass\nos.foo()\n' != 'import os\nif True:\n import re\nos.foo()\n'
E import os
E if True:
E - pass
E + import re
E os.foo()
test_autoflake.py:170: AssertionError
_________________________________________________________________________ UnitTests.test_fix_code __________________________________________________________________________
self = <test_autoflake.UnitTests testMethod=test_fix_code>
def test_fix_code(self):
> self.assertEqual(
"""\
import os
import math
from sys import version
os.foo()
math.pi
x = version
""",
autoflake.fix_code("""\
import os
import re
import abc, math, subprocess
from sys import exit, version
os.foo()
math.pi
x = version
"""))
E AssertionError: 'import os\nimport math\nfrom sys import version\nos.foo()\n[18 chars]on\n' != 'import os\nimport re\nimport abc\nimport math\nimport subpr[60 chars]on\n'
E import os
E + import re
E + import abc
E import math
E + import subprocess
E from sys import version
E os.foo()
E math.pi
E x = version
test_autoflake.py:573: AssertionError
_________________________________________________________________ UnitTests.test_fix_code_with_from_and_as _________________________________________________________________
self = <test_autoflake.UnitTests testMethod=test_fix_code_with_from_and_as>
def test_fix_code_with_from_and_as(self):
> self.assertEqual(
"""\
from collections import namedtuple as xyz
xyz
""",
autoflake.fix_code("""\
from collections import defaultdict, namedtuple as xyz
xyz
"""))
E AssertionError: 'from collections import namedtuple as xyz\nxyz\n' != 'from collections import defaultdict, namedtuple as xyz\nxyz\n'
E - from collections import namedtuple as xyz
E + from collections import defaultdict, namedtuple as xyz
E ? +++++++++++++
E xyz
test_autoflake.py:593: AssertionError
_______________________________________________________ UnitTests.test_fix_code_with_from_and_as_and_escaped_newline _______________________________________________________
self = <test_autoflake.UnitTests testMethod=test_fix_code_with_from_and_as_and_escaped_newline>
def test_fix_code_with_from_and_as_and_escaped_newline(self):
"""Make sure stuff after escaped newline is not lost."""
result = autoflake.fix_code("""\
from collections import defaultdict, namedtuple \\
as xyz
xyz
""")
# We currently leave lines with escaped newlines as is. But in the
# future this we may parse them and remove unused import accordingly.
# For now, we'll work around it here.
result = re.sub(r' *\\\n *as ', ' as ', result)
> self.assertEqual(
"""\
from collections import namedtuple as xyz
xyz
""",
autoflake.fix_code(result))
E AssertionError: 'from collections import namedtuple as xyz\nxyz\n' != 'from collections import defaultdict, namedtuple as xyz\nxyz\n'
E - from collections import namedtuple as xyz
E + from collections import defaultdict, namedtuple as xyz
E ? +++++++++++++
E xyz
test_autoflake.py:705: AssertionError
____________________________________________________________ UnitTests.test_fix_code_with_from_and_depth_module ____________________________________________________________
self = <test_autoflake.UnitTests testMethod=test_fix_code_with_from_and_depth_module>
def test_fix_code_with_from_and_depth_module(self):
> self.assertEqual(
"""\
from distutils.version import StrictVersion
StrictVersion('1.0.0')
""",
autoflake.fix_code("""\
from distutils.version import LooseVersion, StrictVersion
StrictVersion('1.0.0')
"""))
E AssertionError: "from[17 chars]n import StrictVersion\nStrictVersion('1.0.0')\n" != "from[17 chars]n import LooseVersion, StrictVersion\nStrictVersion('1.0.0')\n"
E - from distutils.version import StrictVersion
E + from distutils.version import LooseVersion, StrictVersion
E ? ++++++++++++++
E StrictVersion('1.0.0')
test_autoflake.py:645: AssertionError
________________________________________________________________ UnitTests.test_fix_code_with_indented_from ________________________________________________________________
self = <test_autoflake.UnitTests testMethod=test_fix_code_with_indented_from>
def test_fix_code_with_indented_from(self):
> self.assertEqual(
"""\
def z():
from ctypes import POINTER, byref
POINTER, byref
""",
autoflake.fix_code("""\
def z():
from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref
POINTER, byref
"""))
E AssertionError: 'def [24 chars]port POINTER, byref\n POINTER, byref\n ' != 'def [24 chars]port c_short, c_uint, c_int, c_long, pointer, [36 chars] '
E def z():
E - from ctypes import POINTER, byref
E + from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref
E POINTER, byref
test_autoflake.py:666: AssertionError
__________________________________________________________________ UnitTests.test_standard_package_names ___________________________________________________________________
self = <test_autoflake.UnitTests testMethod=test_standard_package_names>
def test_standard_package_names(self):
> self.assertIn('os', list(autoflake.standard_package_names()))
E AssertionError: 'os' not found in []
test_autoflake.py:77: AssertionError
__________________________________________________________ UnitTests.test_without_ignore_init_module_imports_flag __________________________________________________________
self = <test_autoflake.UnitTests testMethod=test_without_ignore_init_module_imports_flag>
def test_without_ignore_init_module_imports_flag(self):
# Need a temp directory in order to specify file name as __init__.py
temp_directory = tempfile.mkdtemp(dir='.')
temp_file = os.path.join(temp_directory, '__init__.py')
try:
with open(temp_file, 'w') as output:
output.write('import re\n')
p = subprocess.Popen(
list(AUTOFLAKE_COMMAND) + [temp_file],
stdout=subprocess.PIPE)
result = p.communicate()[0].decode('utf-8')
> self.assertIn('import re', result)
E AssertionError: 'import re' not found in ''
test_autoflake.py:568: AssertionError
__________________________________________________________________________ SystemTests.test_diff ___________________________________________________________________________
self = <test_autoflake.SystemTests testMethod=test_diff>
def test_diff(self):
with temporary_file("""\
import re
import os
import my_own_module
x = 1
""") as filename:
output_file = io.StringIO()
autoflake._main(argv=['my_fake_program', filename],
standard_out=output_file,
standard_error=None)
> self.assertEqual("""\
-import re
-import os
import my_own_module
x = 1
""", '\n'.join(output_file.getvalue().split('\n')[3:]))
E AssertionError: '-import re\n-import os\n import my_own_module\n x = 1\n' != ' import re\n-import os\n import my_own_module\n x = 1\n'
E - -import re
E ? ^
E + import re
E ? ^
E -import os
E import my_own_module
E x = 1
test_autoflake.py:1328: AssertionError
_____________________________________________________________ SystemTests.test_diff_with_encoding_declaration ______________________________________________________________
self = <test_autoflake.SystemTests testMethod=test_diff_with_encoding_declaration>
def test_diff_with_encoding_declaration(self):
with temporary_file("""\
# coding: iso-8859-1
import re
import os
import my_own_module
x = 1
""") as filename:
output_file = io.StringIO()
autoflake._main(argv=['my_fake_program', filename],
standard_out=output_file,
standard_error=None)
> self.assertEqual("""\
# coding: iso-8859-1
-import re
-import os
import my_own_module
x = 1
""", '\n'.join(output_file.getvalue().split('\n')[3:]))
E AssertionError: ' # coding: iso-8859-1\n-import re\n-import os\n import my_own_module\n x = 1\n' != ' # coding: iso-8859-1\n import re\n-import os\n import my_own_module\n x = 1\n'
E # coding: iso-8859-1
E - -import re
E ? ^
E + import re
E ? ^
E -import os
E import my_own_module
E x = 1
test_autoflake.py:1354: AssertionError
_______________________________________________________________________ SystemTests.test_end_to_end ________________________________________________________________________
self = <test_autoflake.SystemTests testMethod=test_end_to_end>
def test_end_to_end(self):
with temporary_file("""\
import fake_fake, fake_foo, fake_bar, fake_zoo
import re, os
x = os.sep
print(x)
""") as filename:
process = subprocess.Popen(AUTOFLAKE_COMMAND +
['--imports=fake_foo,fake_bar',
filename],
stdout=subprocess.PIPE)
> self.assertEqual("""\
-import fake_fake, fake_foo, fake_bar, fake_zoo
-import re, os
+import fake_fake
+import fake_zoo
+import os
x = os.sep
print(x)
""", '\n'.join(process.communicate()[0].decode().split('\n')[3:]))
E AssertionError: '-imp[84 chars]ort fake_zoo\n+import os\n x = os.sep\n print(x)\n' != '-imp[84 chars]ort fake_zoo\n+import os\n+import re\n x = os.sep\n print(x)\n'
E -import fake_fake, fake_foo, fake_bar, fake_zoo
E -import re, os
E +import fake_fake
E +import fake_zoo
E +import os
E + +import re
E x = os.sep
E print(x)
test_autoflake.py:1526: AssertionError
________________________________________________________________________ SystemTests.test_in_place _________________________________________________________________________
self = <test_autoflake.SystemTests testMethod=test_in_place>
def test_in_place(self):
with temporary_file("""\
import foo
x = foo
import subprocess
x()
try:
import os
except ImportError:
import os
""") as filename:
output_file = io.StringIO()
autoflake._main(argv=['my_fake_program', '--in-place', filename],
standard_out=output_file,
standard_error=None)
with open(filename) as f:
> self.assertEqual("""\
import foo
x = foo
x()
try:
pass
except ImportError:
pass
""", f.read())
E AssertionError: 'import foo\nx = foo\nx()\n\ntry:\n pass\nexcept ImportError:\n pass\n' != 'import foo\nx = foo\nimport subprocess\nx()\n\ntry:\n pass\[28 chars]ss\n'
E import foo
E x = foo
E + import subprocess
E x()
E
E try:
E pass
E except ImportError:
E pass
test_autoflake.py:1379: AssertionError
_____________________________________________________________ SystemTests.test_in_place_with_with_useless_pass _____________________________________________________________
self = <test_autoflake.SystemTests testMethod=test_in_place_with_with_useless_pass>
def test_in_place_with_with_useless_pass(self):
with temporary_file("""\
import foo
x = foo
import subprocess
x()
try:
pass
import os
except ImportError:
pass
import os
import sys
""") as filename:
output_file = io.StringIO()
autoflake._main(argv=['my_fake_program', '--in-place', filename],
standard_out=output_file,
standard_error=None)
with open(filename) as f:
> self.assertEqual("""\
import foo
x = foo
x()
try:
pass
except ImportError:
pass
""", f.read())
E AssertionError: 'import foo\nx = foo\nx()\n\ntry:\n pass\nexcept ImportError:\n pass\n' != 'import foo\nx = foo\nimport subprocess\nx()\n\ntry:\n pass\[28 chars]ss\n'
E import foo
E x = foo
E + import subprocess
E x()
E
E try:
E pass
E except ImportError:
E pass
test_autoflake.py:1467: AssertionError
========================================================================= short test summary info ==========================================================================
FAILED test_autoflake.py::UnitTests::test_filter_code - AssertionError: 'import os\npass\nos.foo()\n' != 'import os\nimport re\nos.foo()\n'
FAILED test_autoflake.py::UnitTests::test_filter_code_multiline_from_imports - AssertionError: "\\\nimport os\npass\nfrom os.path import (\n join,\n)[78 chars]')\n" !...
FAILED test_autoflake.py::UnitTests::test_filter_code_multiline_imports - AssertionError: '\\\nimport os\npass\nimport os\nos.foo()\n' != '\\\nimport os\nimport re\nimpo...
FAILED test_autoflake.py::UnitTests::test_filter_code_should_ignore_non_standard_library - AssertionError: 'impo[24 chars]ule\npass\nfrom my_package import another_modu[...
FAILED test_autoflake.py::UnitTests::test_filter_code_should_ignore_semicolons - AssertionError: '\\\nimport os\npass\nimport os; import math, subprocess\nos.foo()\n' !=...
FAILED test_autoflake.py::UnitTests::test_filter_code_with_indented_import - AssertionError: 'import os\nif True:\n pass\nos.foo()\n' != 'import os\nif True:\n imp...
FAILED test_autoflake.py::UnitTests::test_fix_code - AssertionError: 'import os\nimport math\nfrom sys import version\nos.foo()\n[18 chars]on\n' != 'import os\nimport re...
FAILED test_autoflake.py::UnitTests::test_fix_code_with_from_and_as - AssertionError: 'from collections import namedtuple as xyz\nxyz\n' != 'from collections import defa...
FAILED test_autoflake.py::UnitTests::test_fix_code_with_from_and_as_and_escaped_newline - AssertionError: 'from collections import namedtuple as xyz\nxyz\n' != 'from col...
FAILED test_autoflake.py::UnitTests::test_fix_code_with_from_and_depth_module - AssertionError: "from[17 chars]n import StrictVersion\nStrictVersion('1.0.0')\n" != "from...
FAILED test_autoflake.py::UnitTests::test_fix_code_with_indented_from - AssertionError: 'def [24 chars]port POINTER, byref\n POINTER, byref\n ' != 'def [24 chars]p...
FAILED test_autoflake.py::UnitTests::test_standard_package_names - AssertionError: 'os' not found in []
FAILED test_autoflake.py::UnitTests::test_without_ignore_init_module_imports_flag - AssertionError: 'import re' not found in ''
FAILED test_autoflake.py::SystemTests::test_diff - AssertionError: '-import re\n-import os\n import my_own_module\n x = 1\n' != ' import re\n-import os\n import my_own_m...
FAILED test_autoflake.py::SystemTests::test_diff_with_encoding_declaration - AssertionError: ' # coding: iso-8859-1\n-import re\n-import os\n import my_own_module\n x = ...
FAILED test_autoflake.py::SystemTests::test_end_to_end - AssertionError: '-imp[84 chars]ort fake_zoo\n+import os\n x = os.sep\n print(x)\n' != '-imp[84 chars]ort fake_zo...
FAILED test_autoflake.py::SystemTests::test_in_place - AssertionError: 'import foo\nx = foo\nx()\n\ntry:\n pass\nexcept ImportError:\n pass\n' != 'import foo\nx = ...
FAILED test_autoflake.py::SystemTests::test_in_place_with_with_useless_pass - AssertionError: 'import foo\nx = foo\nx()\n\ntry:\n pass\nexcept ImportError:\n pass\...
====================================================================== 18 failed, 101 passed in 4.12s ======================================================================
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
1.4.2: pytest is failing · Issue #94 - GitHub
I think I know why it failed. I have installed randomly pytest extension which is causing that each time pytest units are executed...
Read more >python - Pytest - error vs fail - Stack Overflow
For pytest, any uncaught exception thrown in a test function is a failure, including but not limited to assertion errors.
Read more >Changelog — pytest documentation
After 6.2.0, these types began failing, because they inherited neither from standard Python number hierarchy nor from numpy.ndarray .
Read more >pytest delayed assert / multiple failure plugin, iteration 1
pytest delayed assert / multiple failure plugin, iteration 1 ... platform darwin -- Python 2.7.9 -- py-1.4.26 -- pytest-2.6.4 collected 2 ...
Read more >pandas code style guide — pandas 1.4.0 documentation
Do not use this method. It has the same behavior as pytest.skip , namely it immediately stops the test and does not check...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sound plausible. The distutils.sysconfig module hijacked by setuptools 60+ reports the wrong platformdir.
/usr/lib/
instead of/usr/lib64/
for 64bit architectures.The output is very similar, although not exactly the same, as OP used pytest and reported the issues back in January with autoflake 1.4.
Here is the output from a third slightly different setup than the docker reproducer. It is a bit closer to OP’s as we are like him using the tests to validate rpm package integrity.