Skip to content

Commit

Permalink
UnittestTester operational and used for unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb-sitton-inl committed Sep 23, 2024
1 parent 11195e0 commit d2a6ade
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
2 changes: 1 addition & 1 deletion developer_tools/rook.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[rook]
add_non_default_run_types = qsub
testers_dir = HERON/src/Testers
testers_dir = HERON/src/Testers, src/Testers
test_dir = tests
2 changes: 1 addition & 1 deletion run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ case $TEST_SET in
;;
esac

$PYTHON_COMMAND $SCRIPT_DIR/raven/rook/main.py --config-file=$SCRIPT_DIR/developer_tools/rook.ini --test-dir $TEST_DIR --testers-dir $RAVEN_DIR/scripts/TestHarness/testers,$RAVEN_DIR/../HERON/src/Testers "${ARGS[@]}"
$PYTHON_COMMAND $SCRIPT_DIR/raven/rook/main.py --config-file=$SCRIPT_DIR/developer_tools/rook.ini --test-dir $TEST_DIR --testers-dir $RAVEN_DIR/scripts/TestHarness/testers,$RAVEN_DIR/../HERON/src/Testers,$RAVEN_DIR/../src/Testers "${ARGS[@]}"

# store return codes individually (rc) and combined (ALL_PASS)
rc=$?
Expand Down
15 changes: 10 additions & 5 deletions UnittestTester.py → src/Testers/UnittestTester.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import os
from raven.scripts import library_handler
from raven.scripts.TestHarness.testers import RavenPython
import sys

FORCE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
sys.path.append(FORCE_DIR)
from raven.scripts.TestHarness.testers.RavenPython import RavenPython
# clear scripts from path
sys.path.pop()

try:
import unittest
unittest_found = True
except ModuleNotFoundError or ImportError:
unittest_found = False

class UnittestTester(RavenPython):
class Unittest(RavenPython):
"""
This class simplifies use of the unittest module for running unit tests through rook.
"""
Expand All @@ -22,8 +27,8 @@ def get_valid_params():
@ Out, params, _ValidParameters, the parameters for this class.
"""
params = RavenPython.get_valid_params()
# 'input' param can be test case or test suite; unittest will handle either when called
params.add_param('unittest_args', '', "Arguments to the unittest module")
params.add_param('test_sequence_to_run', '', "Ordered list of test cases in the input file to run")
return params

def __init__(self, name, params):
Expand Down Expand Up @@ -62,4 +67,4 @@ def get_command(self):
pythonCommand = self._get_python_command()
else:
pythonCommand = self.specs["python_command"]
return pythonCommand+" "+self.specs["input"]
return ' '.join([pythonCommand, '-m unittest', self.specs["unittest_args"], self.specs["input"]])
36 changes: 18 additions & 18 deletions tests/unit_tests/tests
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
[Tests]
[./TestMinimalInput]
type = RavenPython
input = '-m unittest test_heron.TestMinimalInput'
type = Unittest
input = 'test_heron.TestMinimalInput'
[../]

[./TestExpandedInput1]
type = RavenPython
input = '-m unittest test_heron.TestExpandedInput1'
type = Unittest
input = 'test_heron.TestExpandedInput1'
[../]

[./TestExpandedInput2]
type = RavenPython
input = '-m unittest test_heron.TestExpandedInput2'
type = Unittest
input = 'test_heron.TestExpandedInput2'
[../]

[./TestNoComponentsNode]
type = RavenPython
input = '-m unittest test_heron.TestNoComponentsNode'
type = Unittest
input = 'test_heron.TestNoComponentsNode'
[../]

[./TestNoComponentNodes]
type = RavenPython
input = '-m unittest test_heron.TestNoComponentNodes'
type = Unittest
input = 'test_heron.TestNoComponentNodes'
[../]

[./TestMissingSubnodes]
type = RavenPython
input = '-m unittest test_heron.TestMissingSubnodes'
type = Unittest
input = 'test_heron.TestMissingSubnodes'
[../]

[./TestEmptyCompSetsFolder]
type = RavenPython
input = '-m unittest test_heron.TestEmptyCompSetsFolder'
type = Unittest
input = 'test_heron.TestEmptyCompSetsFolder'
[../]

[./TestCompSetsFolderWithBadJSON]
type = RavenPython
input = '-m unittest test_heron.TestCompSetsFolderWithBadJSON'
type = Unittest
input = 'test_heron.TestCompSetsFolderWithBadJSON'
[../]

[./TestCompSetsFolderMultFiles]
type = RavenPython
input = '-m unittest test_heron.TestCompSetsFolderMultFiles'
type = Unittest
input = 'test_heron.TestCompSetsFolderMultFiles'
[../]
[]

0 comments on commit d2a6ade

Please sign in to comment.