| from __future__ import absolute_import |
| from __future__ import print_function |
| from __future__ import unicode_literals |
| from pre_commit_hooks.string_fixer import main |
| (r"'\"\"'", r"'\"\"'", 0), |
| # String somewhere in the line |
| ('x = "foo"', "x = 'foo'", 1), |
| # Test escaped characters |
| ('""" Foo """', '""" Foo """', 0), |
| ('"foo""bar"', "'foo''bar'", 1), |
| @pytest.mark.parametrize(('input_s', 'output', 'expected_retval'), TESTS) |
| def test_rewrite(input_s, output, expected_retval, tmpdir): |
| path = tmpdir.join('file.txt') |
| retval = main([path.strpath]) |
| assert path.read() == output |
| assert retval == expected_retval |