Skip to content

Commit

Permalink
Ignore DeprecationWarnings to fix tests on py3.11
Browse files Browse the repository at this point in the history
Pass `-Wignore::DeprecationWarning` when spawning autopep8 in tests
to fix the two test failures when running on Python 3.11:

```
======================================================================
FAIL: test_in_place_no_modifications_no_writes (__main__.CommandLineTests.test_in_place_no_modifications_no_writes)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/autopep8/test/test_autopep8.py", line 5518, in test_in_place_no_modifications_no_writes
    self.assertEqual(err, b'')
AssertionError: b'/tmp/autopep8/autopep8.py:182: Deprecatio[137 chars]ze\n' != b''

======================================================================
FAIL: test_in_place_no_modifications_no_writes_with_empty_file (__main__.CommandLineTests.test_in_place_no_modifications_no_writes_with_empty_file)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/autopep8/test/test_autopep8.py", line 5530, in test_in_place_no_modifications_no_writes_with_empty_file
    self.assertEqual(err, b'')
AssertionError: b'/tmp/autopep8/autopep8.py:182: Deprecatio[137 chars]ze\n' != b''
```

This is a temporary fix until issue #581 is resolved.
  • Loading branch information
mgorny committed Dec 16, 2022
1 parent 3555a19 commit 75b444d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/test_autopep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@
)

if 'AUTOPEP8_COVERAGE' in os.environ and int(os.environ['AUTOPEP8_COVERAGE']):
AUTOPEP8_CMD_TUPLE = ('coverage', 'run', '--branch', '--parallel',
AUTOPEP8_CMD_TUPLE = (sys.executable, '-Wignore::DeprecationWarning',
'-m', 'coverage', 'run', '--branch', '--parallel',
'--omit=*/site-packages/*',
os.path.join(ROOT_DIR, 'autopep8.py'),)
else:
# We need to specify the executable to make sure the correct Python
# interpreter gets used.
AUTOPEP8_CMD_TUPLE = (sys.executable,
AUTOPEP8_CMD_TUPLE = (sys.executable, '-Wignore::DeprecationWarning',
os.path.join(ROOT_DIR,
'autopep8.py'),) # pragma: no cover

Expand Down

0 comments on commit 75b444d

Please sign in to comment.