pre-commit-hooks/testing/util.py
Sviatoslav Sydorenko 51f8cc8ff0 Use open built-in to open files
* This makes Python 3 not raise UnicodeDecodeError when reading files
2016-12-29 18:53:57 +02:00

17 lines
434 B
Python

from __future__ import absolute_import
from __future__ import unicode_literals
import os.path
TESTING_DIR = os.path.abspath(os.path.dirname(__file__))
def get_resource_path(path):
return os.path.join(TESTING_DIR, 'resources', path)
def write_file(filename, contents):
"""Hax because coveragepy chokes on nested context managers."""
with open(filename, 'w', newline='') as file_obj:
file_obj.write(contents)