Fix setting for default test suite directory
@@ -138,7 +138,8 @@ class BaseTarget(metaclass=ABCMeta):
class TestGenerator:
"""Generate test cases and write to data files."""
def __init__(self, options) -> None:
- self.test_suite_directory = getattr(options, 'directory', 'tests/suites')
+ self.test_suite_directory = self.get_option(options, 'directory',
+ 'tests/suites')
# Update `targets` with an entry for each child class of BaseTarget.
# Each entry represents a file generated by the BaseTarget framework,
# and enables generating the .data files using the CLI.
@@ -147,6 +148,11 @@ class TestGenerator:
for subclass in BaseTarget.__subclasses__()
})
+ @staticmethod
+ def get_option(options, name: str, default: T) -> T:
+ value = getattr(options, name, None)
+ return default if value is None else value
+
def filename_for(self, basename: str) -> str:
"""The location of the data file with the specified base name."""
return posixpath.join(self.test_suite_directory, basename + '.data')
