class_docstr: Example runner.
  
  A single runner can run multiple script commands.
  A runner creates a temporary directory and files in the respective example
  directory are copied there.
  All the runs are executed within the temporary directory as the current
  directory.
class_docstr_tok: ["Example","runner",".","A","single","runner","can","run","multiple","script","commands",".","A","runner","creates","a","temporary","directory","and","files","in","the","respective","example","directory","are","copied","there",".","All","the","runs","are","executed","within","the","temporary","directory","as","the","current","directory","."]
docstr: Checks correctness of the replacement file comparing with the
  original file.
docstr_tok: ["Checks","correctness","of","the","replacement","file","comparing","with","the","original","file","."]
code: def _check_replace_file_correct(self, orig_path, replace_path):
      """Checks correctness of the replacement file comparing with the
      original file."""
  
      MARKER_BEGIN = "# BEGIN ADDITIONAL TEST CODE"
      MARKER_END = "# END ADDITIONAL TEST CODE"
  
      # Read lines from both files.
      with open(orig_path, "r") as orig_file:
          orig_lines = orig_file.readlines()
      with open(replace_path, "r") as replace_file:
          replace_lines = replace_file.readlines()
  
      j = 0  # line number (replace)
      for i, orig_line in enumerate(orig_lines):
          if len(replace_lines) <= j:
              raise ReplacementFileCorrectnessError(
                  "Replacement file has less lines than the original.",
                  orig_path=orig_path,
                  replace_path=replace_path,
              )
          replace_line = replace_lines[j]
          j += 1
  
          # Check if the line is a starting marker comment.
          # Marker line can start with arbitrary number of spaces (indent).
          if replace_line.endswith(MARKER_BEGIN + "\n") and all(
              " " == c for c in replace_line[: -len(MARKER_BEGIN) - 1]
          ):
              # Starting marker is found: find the corresponding ending
              # marker and retrieve the next line.
              indent_count = len(replace_line) - len(MARKER_BEGIN) - 1
              end_marker_line = " " * indent_count + MARKER_END + "\n"
              j_ = j
              while True:
                  if len(replace_lines) <= j_:
                      raise ReplacementFileCorrectnessError(
                          "Matching ending marker could not be found in a "
                          "replacement file.",
                          orig_path=orig_path,
                          replace_path=replace_path,
                          orig_line_num=i,
                          replace_line_num=j,
                          orig_line=orig_line.rstrip("\n"),
                          replace_line=replace_line.rstrip("\n"),
                      )
                  if replace_lines[j_] == end_marker_line:
                      break
                  j_ += 1
              j = j_ + 1
  
              replace_line = replace_lines[j]
              j += 1
  
          # Compare the next non-marked lines.
          if orig_line != replace_line:
              raise ReplacementFileCorrectnessError(
                  "Line mismatch between the original and the replacement "
                  "file.",
                  orig_path=orig_path,
                  replace_path=replace_path,
                  orig_line_num=i,
                  replace_line_num=j,
                  orig_line=orig_line.rstrip("\n"),
                  replace_line=replace_line.rstrip("\n"),
              )
  
      if j != len(replace_lines):
          raise ReplacementFileCorrectnessError(
              "Replacement file has more lines than the original.",
              orig_path=orig_path,
              replace_path=replace_path,
          )
  
imports: import contextlib
  import os
  import re
  import shutil
  import subprocess
  import sys
  import tempfile
label_desc: Use image node_id 6 for calling the ExampleRunner obj's underlying member method code with example usage: obj._check_replace_file_correct(orig_path, replace_path) without return types