<commit_before># Copyright (c) 2017 The Regents of the University of Michigan.
# All Rights Reserved. Licensed according to the terms of the Revised
# BSD License. See LICENSE.txt for details.
source "bin/test/make_backwards_compatible/includes.sh"

setup() {
  tmpfile="$(mktemp source_file_XXXXXX.py)"
  echo "except ConnectionError:"        >> "$tmpfile"
  echo "    pass"                       >> "$tmpfile"
  echo "except BrokenPipe:"             >> "$tmpfile"
  echo "    pass"                       >> "$tmpfile"
  echo "except ConnectionAbortedError:" >> "$tmpfile"
  echo "    pass"                       >> "$tmpfile"
  echo "except ConnectionRefusedError:" >> "$tmpfile"
  echo "    pass"                       >> "$tmpfile"
  echo "except ConnectionResetError:"   >> "$tmpfile"
  echo "    pass"                       >> "$tmpfile"
}

teardown() {
  rm "$tmpfile"
}

make_compatible_325() {
  make_compatible --version 3.2.5 "$@"
}

@test "ConnectionError becomes OSError in <3.3" {
  run make_compatible_325 "$tmpfile"
  [ "$status" -eq 0 ]
  not_grep ConnectionError "$tmpfile"
  grep -q '^except OSError:$' "$tmpfile"
  grep -q '^ \+pass$' "$tmpfile"
}

@test "BrokenPipe becomes OSError in <3.3" {
  run make_compatible_325 "$tmpfile"
  [ "$status" -eq 0 ]
  not_grep BrokenPipe "$tmpfile"
}

@test "ConnectionAbortedError becomes OSError in <3.3" {
  run make_compatible_325 "$tmpfile"
  [ "$status" -eq 0 ]
  not_grep ConnectionAbortedError "$tmpfile"
}

@test "ConnectionRefusedError becomes OSError in <3.3" {
  run make_compatible_325 "$tmpfile"
  [ "$status" -eq 0 ]
  not_grep ConnectionRefusedError "$tmpfile"
}

@test "ConnectionResetError becomes OSError in <3.3" {
  run make_compatible_325 "$tmpfile"
  [ "$status" -eq 0 ]
  not_grep ConnectionResetError "$tmpfile"
}

@test "ConnectionError and BrokenPipe become OSError in <3.3" {
  run make_compatible_325 "$tmpfile"
  [ "$status" -eq 0 ]
  not_grep ConnectionError "$tmpfile"
  not_grep BrokenPipe "$tmpfile"
  grep -q '^except OSError:$' "$tmpfile"
  grep -q '^ \+pass$' "$tmpfile"
}

@test "ConnectionError is fine if python >=3.3" {
  run make_compatible --version 3.3.0 "$tmpfile"
  grep -q ConnectionError "$tmpfile"
}<commit_msg>Use make_compatible_32 instead of make_compatible_325<commit_after># Copyright (c) 2017 The Regents of the University of Michigan.
# All Rights Reserved. Licensed according to the terms of the Revised
# BSD License. See LICENSE.txt for details.
source "bin/test/make_backwards_compatible/includes.sh"

setup() {
  tmpfile="$(mktemp source_file_XXXXXX.py)"
  echo "except ConnectionError:"        >> "$tmpfile"
  echo "    pass"                       >> "$tmpfile"
  echo "except BrokenPipe:"             >> "$tmpfile"
  echo "    pass"                       >> "$tmpfile"
  echo "except ConnectionAbortedError:" >> "$tmpfile"
  echo "    pass"                       >> "$tmpfile"
  echo "except ConnectionRefusedError:" >> "$tmpfile"
  echo "    pass"                       >> "$tmpfile"
  echo "except ConnectionResetError:"   >> "$tmpfile"
  echo "    pass"                       >> "$tmpfile"
}

teardown() {
  rm "$tmpfile"
}

make_compatible_325() {
  make_compatible --version 3.2.5 "$@"
}

@test "ConnectionError becomes OSError in <3.3" {
  run make_compatible_32 "$tmpfile"
  [ "$status" -eq 0 ]
  not_grep ConnectionError "$tmpfile"
  grep -q '^except OSError:$' "$tmpfile"
  grep -q '^ \+pass$' "$tmpfile"
}

@test "BrokenPipe becomes OSError in <3.3" {
  run make_compatible_32 "$tmpfile"
  [ "$status" -eq 0 ]
  not_grep BrokenPipe "$tmpfile"
}

@test "ConnectionAbortedError becomes OSError in <3.3" {
  run make_compatible_32 "$tmpfile"
  [ "$status" -eq 0 ]
  not_grep ConnectionAbortedError "$tmpfile"
}

@test "ConnectionRefusedError becomes OSError in <3.3" {
  run make_compatible_32 "$tmpfile"
  [ "$status" -eq 0 ]
  not_grep ConnectionRefusedError "$tmpfile"
}

@test "ConnectionResetError becomes OSError in <3.3" {
  run make_compatible_32 "$tmpfile"
  [ "$status" -eq 0 ]
  not_grep ConnectionResetError "$tmpfile"
}

@test "ConnectionError and BrokenPipe become OSError in <3.3" {
  run make_compatible_32 "$tmpfile"
  [ "$status" -eq 0 ]
  not_grep ConnectionError "$tmpfile"
  not_grep BrokenPipe "$tmpfile"
  grep -q '^except OSError:$' "$tmpfile"
  grep -q '^ \+pass$' "$tmpfile"
}

@test "ConnectionError is fine if python >=3.3" {
  run make_compatible --version 3.3.0 "$tmpfile"
  grep -q ConnectionError "$tmpfile"
}
{'fraction_non_alphanumeric': 0.13339301700984782, 'fraction_numerical': 0.022605192479856758, 'mean_word_length': 3.2360189573459714, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6442716', 'n_tokens_mistral': 1592, 'n_tokens_neox': 1499, 'n_words': 412}