if(NOT TARGET aeveon_decoder_py)
	return()
endif()

find_package(
	Python
	COMPONENTS Interpreter
	REQUIRED)

file(
	GLOB
	test_files
	CONFIGURE_DEPENDS
	"${CMAKE_CURRENT_SOURCE_DIR}/test_*.py")

foreach(test_file IN LISTS test_files)
	get_filename_component(test_name ${test_file} NAME_WE)
	add_test(
		NAME ${test_name}
		COMMAND ${Python_EXECUTABLE} -m pytest -ra ${test_file}
		WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
	set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "PYTHONPATH=$<TARGET_FILE_DIR:aeveon_decoder_py>")
endforeach()
