Use CTest to run Python tests

Avoid having to copy the test script by modifying PYTHONPATH at runtime,
and move the test script into the test directory.
This commit is contained in:
Oliver Hamlet
2019-03-25 08:38:34 +00:00
parent a35abab104
commit 06a6d9ceb6
2 changed files with 11 additions and 6 deletions
+5 -5
View File
@@ -106,11 +106,11 @@ add_custom_command(TARGET loot_api POST_BUILD
"${LIBLOOT_EXTRACTED_PATH}/${LIBLOOT_SHARED_LIBRARY}"
"$<TARGET_FILE_DIR:loot_api>/${LIBLOOT_SHARED_LIBRARY}")
# Copy the test Python script to the build directory.
add_custom_command(TARGET loot_api POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_SOURCE_DIR}/src/test.py"
"$<TARGET_FILE_DIR:loot_api>/test.py")
enable_testing()
add_test(NAME python
WORKING_DIRECTORY $<TARGET_FILE_DIR:loot_api>
COMMAND "${PYTHON_EXECUTABLE}" ${CMAKE_SOURCE_DIR}/test/test.py)
########################################
# Install
+6 -1
View File
@@ -1,9 +1,14 @@
#!/usr/bin/env python
import cProfile
import os
import os.path
import shutil
import sys
import unittest
sys.path.append(os.getcwd())
from loot_api import Version
from loot_api import WrapperVersion
from loot_api import GameType
@@ -63,7 +68,7 @@ class TestLootApi(GameFixture):
self.assertNotEqual(db, None)
class TestDatabaseInterface(GameFixture):
masterlist_path = u'../../test/masterlist.yaml'
masterlist_path = os.path.join(os.path.dirname(__file__), u'masterlist.yaml')
def setUp(self):
super(TestDatabaseInterface, self).setUp()