mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 00:04:42 +04:00
Fix several ResourceWarning: unclosed file
This commit is contained in:
parent
abee146199
commit
67d6fcb0f6
10 changed files with 78 additions and 34 deletions
|
|
@ -21,6 +21,26 @@ from testing.fixtures import write_config
|
|||
from testing.util import cwd
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def no_warnings(recwarn):
|
||||
yield
|
||||
warnings = []
|
||||
for warning in recwarn: # pragma: no cover
|
||||
message = str(warning.message)
|
||||
# ImportWarning: Not importing directory '...' missing __init__(.py)
|
||||
if not (
|
||||
isinstance(warning.message, ImportWarning)
|
||||
and message.startswith('Not importing directory ')
|
||||
and ' missing __init__' in message
|
||||
):
|
||||
warnings.append('{}:{} {}'.format(
|
||||
warning.filename,
|
||||
warning.lineno,
|
||||
message,
|
||||
))
|
||||
assert not warnings
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tempdir_factory(tmpdir):
|
||||
class TmpdirFactory(object):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue