<commit_before>include(CMakeParseArguments)

set(py_coverage_rc "${PROJECT_BINARY_DIR}/tests/romanesco.coveragerc")
set(flake8_config "${PROJECT_SOURCE_DIR}/tests/flake8.cfg")
set(coverage_html_dir "${PROJECT_SOURCE_DIR}/docs/_build/html/py_coverage")
set(py_testdir "${PROJECT_SOURCE_DIR}/tests")

if(PYTHON_BRANCH_COVERAGE)
  set(_py_branch_cov True)
else()
  set(_py_branch_cov False)
endif()

configure_file(
  "${PROJECT_SOURCE_DIR}/tests/romanesco.coveragerc.in"
  "${py_coverage_rc}"
  @ONLY
)

function(add_python_flake8_test name input)
  add_test(
    NAME ${name}
    WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
    COMMAND "${FLAKE8_EXECUTABLE}" "--config=${flake8_config}" "${input}"
  )
endfunction()

function(add_python_test case)
  set(name "${case}")

  set(_multival_args "")
  set(_args PLUGIN PLUGINS_ENABLED)
  cmake_parse_arguments(fn "${_options}" "${_args}" "${_multival_args}" ${ARGN})


  if (fn_PLUGIN)
    set(name "plugins.${fn_PLUGIN}.${case}")
    set(module romanesco.plugins.${fn_PLUGIN}.tests.${case}_test)
  else()
    set(module tests.${case}_test)
  endif()

  if(PYTHON_COVERAGE)
    add_test(
      NAME ${name}
      WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
      COMMAND "${PYTHON_COVERAGE_EXECUTABLE}" run -p --append "--rcfile=${py_coverage_rc}"
              "--source=romanesco" -m unittest -v ${module}
    )
  else()
    add_test(
      NAME ${name}
      WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
      COMMAND "${PYTHON_EXECUTABLE}" -m unittest -v ${module}
    )
  endif()

  if(PYTHON_COVERAGE)
    set_property(TEST ${name} APPEND PROPERTY DEPENDS py_coverage_reset)
    set_property(TEST py_coverage_combine APPEND PROPERTY DEPENDS ${name})
  endif()

  if(fn_PLUGINS_ENABLED)
    set_property(TEST ${name} PROPERTY ENVIRONMENT
      "ROMANESCO_PLUGINS_ENABLED=${fn_PLUGINS_ENABLED}"
    )
  else()
    set_property(TEST ${name} PROPERTY ENVIRONMENT
      "ROMANESCO_PLUGINS_ENABLED="
    )
  endif()
endfunction()

function(add_docstring_test module)
  set(name doctest:${module})
  if(PYTHON_COVERAGE)
    add_test(
      NAME ${name}
      WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
      COMMAND "${PYTHON_COVERAGE_EXECUTABLE}" run -p --append "--rcfile=${py_coverage_rc}"
              "--source=romanesco" "${py_testdir}/docstring_test.py" -v ${module}
    )
  else()
    add_test(
      NAME ${name}
      WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
      COMMAND "${PYTHON_EXECUTABLE}" "${py_testdir}/docstring_test.py" -v ${module}
    )
  endif()
  if(PYTHON_COVERAGE)
    set_property(TEST ${name} APPEND PROPERTY DEPENDS py_coverage_reset)
    set_property(TEST py_coverage_combine APPEND PROPERTY DEPENDS ${name})
  endif()
endfunction()<commit_msg>Fix tests to work with Coverage 4.0<commit_after>include(CMakeParseArguments)

set(py_coverage_rc "${PROJECT_BINARY_DIR}/tests/romanesco.coveragerc")
set(flake8_config "${PROJECT_SOURCE_DIR}/tests/flake8.cfg")
set(coverage_html_dir "${PROJECT_SOURCE_DIR}/docs/_build/html/py_coverage")
set(py_testdir "${PROJECT_SOURCE_DIR}/tests")

if(PYTHON_BRANCH_COVERAGE)
  set(_py_branch_cov True)
else()
  set(_py_branch_cov False)
endif()

configure_file(
  "${PROJECT_SOURCE_DIR}/tests/romanesco.coveragerc.in"
  "${py_coverage_rc}"
  @ONLY
)

function(add_python_flake8_test name input)
  add_test(
    NAME ${name}
    WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
    COMMAND "${FLAKE8_EXECUTABLE}" "--config=${flake8_config}" "${input}"
  )
endfunction()

function(add_python_test case)
  set(name "${case}")

  set(_multival_args "")
  set(_args PLUGIN PLUGINS_ENABLED)
  cmake_parse_arguments(fn "${_options}" "${_args}" "${_multival_args}" ${ARGN})


  if (fn_PLUGIN)
    set(name "plugins.${fn_PLUGIN}.${case}")
    set(module romanesco.plugins.${fn_PLUGIN}.tests.${case}_test)
  else()
    set(module tests.${case}_test)
  endif()

  if(PYTHON_COVERAGE)
    add_test(
      NAME ${name}
      WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
      COMMAND "${PYTHON_COVERAGE_EXECUTABLE}" run --parallel-mode "--rcfile=${py_coverage_rc}"
              "--source=romanesco" -m unittest -v ${module}
    )
  else()
    add_test(
      NAME ${name}
      WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
      COMMAND "${PYTHON_EXECUTABLE}" -m unittest -v ${module}
    )
  endif()

  if(PYTHON_COVERAGE)
    set_property(TEST ${name} APPEND PROPERTY DEPENDS py_coverage_reset)
    set_property(TEST py_coverage_combine APPEND PROPERTY DEPENDS ${name})
  endif()

  if(fn_PLUGINS_ENABLED)
    set_property(TEST ${name} PROPERTY ENVIRONMENT
      "ROMANESCO_PLUGINS_ENABLED=${fn_PLUGINS_ENABLED}"
    )
  else()
    set_property(TEST ${name} PROPERTY ENVIRONMENT
      "ROMANESCO_PLUGINS_ENABLED="
    )
  endif()
endfunction()

function(add_docstring_test module)
  set(name doctest:${module})
  if(PYTHON_COVERAGE)
    add_test(
      NAME ${name}
      WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
      COMMAND "${PYTHON_COVERAGE_EXECUTABLE}" run --parallel-mode "--rcfile=${py_coverage_rc}"
              "--source=romanesco" "${py_testdir}/docstring_test.py" -v ${module}
    )
  else()
    add_test(
      NAME ${name}
      WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
      COMMAND "${PYTHON_EXECUTABLE}" "${py_testdir}/docstring_test.py" -v ${module}
    )
  endif()
  if(PYTHON_COVERAGE)
    set_property(TEST ${name} APPEND PROPERTY DEPENDS py_coverage_reset)
    set_property(TEST py_coverage_combine APPEND PROPERTY DEPENDS ${name})
  endif()
endfunction()
{'fraction_non_alphanumeric': 0.1376971030436377, 'fraction_numerical': 0.0022002200220022, 'mean_word_length': 4.589139344262295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5595559', 'n_tokens_mistral': 2075, 'n_tokens_neox': 2045, 'n_words': 325}