From d3a93e6d1eec86a2982bc8b519a6e1b239f66c28 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 11 Aug 2016 23:08:13 -0700 Subject: [PATCH] Use py.path in one more place --- testing/util.py | 7 ------- tests/check_merge_conflict_test.py | 6 +++--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/testing/util.py b/testing/util.py index 837a3cb..fac498c 100644 --- a/testing/util.py +++ b/testing/util.py @@ -1,7 +1,6 @@ from __future__ import absolute_import from __future__ import unicode_literals -import io import os.path @@ -10,9 +9,3 @@ 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 io.open(filename, 'w', newline='') as file_obj: - file_obj.write(contents) diff --git a/tests/check_merge_conflict_test.py b/tests/check_merge_conflict_test.py index 8141ade..ada82a9 100644 --- a/tests/check_merge_conflict_test.py +++ b/tests/check_merge_conflict_test.py @@ -5,11 +5,11 @@ import os import shutil import pytest +from py.path import local from pre_commit_hooks.check_merge_conflict import detect_merge_conflict from pre_commit_hooks.util import cmd_output from testing.util import get_resource_path -from testing.util import write_file # pylint:disable=unused-argument @@ -106,7 +106,7 @@ def test_merge_conflicts_git(): ) @pytest.mark.usefixtures('repository_is_pending_merge') def test_merge_conflicts_failing(failing_contents): - write_file('f2', failing_contents) + local('f2').write(failing_contents) assert detect_merge_conflict(['f2']) == 1 @@ -115,7 +115,7 @@ def test_merge_conflicts_failing(failing_contents): ) @pytest.mark.usefixtures('f1_is_a_conflict_file') def test_merge_conflicts_ok(ok_contents): - write_file('f1', ok_contents) + local('f1').write(ok_contents) assert detect_merge_conflict(['f1']) == 0