| from pre_commit_hooks.detect_private_key import detect_private_key |
| # Input, expected return value |
| (b'-----BEGIN RSA PRIVATE KEY-----', 1), |
| (b'-----BEGIN DSA PRIVATE KEY-----', 1), |
| (b'-----BEGIN EC PRIVATE KEY-----', 1), |
| # Some arbitrary binary data |
| (b'\xa2\xf1\x93\x12', 0), |
| @pytest.mark.parametrize(('input_s', 'expected_retval'), TESTS) |
| def test_detect_private_key(input_s, expected_retval, tmpdir): |
| path = os.path.join(tmpdir.strpath, 'file.txt') |
| with open(path, 'wb') as file_obj: |
| assert detect_private_key([path]) == expected_retval |