Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,102 @@ junit_log_passing_tests = true

[tool.pytest_env]
RUST_BACKTRACE = {value = "1", skip_if_set = true}

[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]

line-length = 120
indent-width = 4

[tool.ruff.lint]
select = [
# flake8-boolean-trap
"FBT",
# flake8-bugbear
"B",
# flake8-builtins
"A",
# flake8-comprehensions
"C4",
# flake8-fixme
"FIX",
# flake8-implicit-str-concat
"ISC",
# flake8-pie
"PIE",
# flake8-print
"T20",
# flake8-pytest-style
"PT",
# flake8-raise
"RSE",
# flake8-return
"RET501",
"RET502",
"RET503",
"RET504",
# flake8-self
"SLF",
# flake8-simplify
"SIM",
# flake8-type-checking
"TC",
# flake8-unused-arguments
"ARG",
# flake8-use-pathlib
"PTH",

# isort
"I",

# pycodestyle error
"E",
# Pyflakes
"F",
# pyupgrade
"UP",
]
ignore = ["F401", "PTH123", "ARG002"]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
4 changes: 1 addition & 3 deletions tests/test_cases/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ def build_tools(self, version: str) -> BuildTools:
return BazelTools(option_prefix=version)

@pytest.fixture(scope="class")
def temp_dir(
self, tmp_path_factory: pytest.TempPathFactory, version: str
) -> Generator[Path, None, None]:
def temp_dir(self, tmp_path_factory: pytest.TempPathFactory, version: str) -> Generator[Path, None, None]:
yield from temp_dir_common(tmp_path_factory, self.__class__.__name__, version)

@pytest.fixture(scope="class")
Expand Down
12 changes: 3 additions & 9 deletions tests/test_cases/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,16 @@ def pytest_terminal_summary(terminalreporter):
return
# Print failed scenarios info
terminalreporter.write_sep("=", "Failed tests reproduction info")
terminalreporter.write_line(
"Run failed scenarios from the repo root working directory\n"
)
terminalreporter.write_line("Run failed scenarios from the repo root working directory\n")

for entry in FAILED_CONFIGS:
terminalreporter.write_line(
f"{entry['nodeid']} | Run command:\n{entry['command']}\n"
)
terminalreporter.write_line(f"{entry['nodeid']} | Run command:\n{entry['command']}\n")


def pytest_collection_modifyitems(items: list[pytest.Function]):
for item in items:
# Automatically mark tests parametrized with 'version' as 'cpp' or 'rust'
if hasattr(item, "callspec") and "version" in getattr(
item.callspec, "params", {}
):
if hasattr(item, "callspec") and "version" in getattr(item.callspec, "params", {}):
version = item.callspec.params["version"]
if version == "cpp":
item.add_marker(pytest.mark.cpp)
Expand Down
56 changes: 14 additions & 42 deletions tests/test_cases/tests/test_cit_default_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ def create_defaults_json(values: dict[str, TaggedValue]) -> str:
return json.dumps(json_value)


def create_defaults_file(
dir_path: Path, instance_id: int, values: dict[str, TaggedValue]
) -> Path:
def create_defaults_file(dir_path: Path, instance_id: int, values: dict[str, TaggedValue]) -> Path:
"""
Create file containing default values, along with a matching hash file.
Returns path to default values file.
Expand Down Expand Up @@ -84,9 +82,7 @@ def temp_dir(
"""
Create temporary directory and remove it after test.
"""
yield from temp_dir_common(
tmp_path_factory, self.__class__.__name__, version, defaults
)
yield from temp_dir_common(tmp_path_factory, self.__class__.__name__, version, defaults)


@pytest.mark.PartiallyVerifies(
Expand Down Expand Up @@ -132,9 +128,7 @@ def defaults_file(self, temp_dir: Path, defaults: str) -> Path | None:
if defaults == "without":
return None

return create_defaults_file(
temp_dir, self.instance_id(), {self.KEY: ("f64", self.VALUE)}
)
return create_defaults_file(temp_dir, self.instance_id(), {self.KEY: ("f64", self.VALUE)})

def test_valid(
self,
Expand All @@ -144,9 +138,7 @@ def test_valid(
version: str,
) -> None:
if version == "cpp":
pytest.xfail(
reason="https://github.com/eclipse-score/persistency/issues/182"
)
pytest.xfail(reason="https://github.com/eclipse-score/persistency/issues/182")

assert results.return_code == ResultCode.SUCCESS

Expand Down Expand Up @@ -216,9 +208,7 @@ def defaults_file(self, temp_dir: Path, defaults: str) -> Path | None:
if defaults == "without":
return None

return create_defaults_file(
temp_dir, self.instance_id(), {self.KEY: ("f64", self.VALUE)}
)
return create_defaults_file(temp_dir, self.instance_id(), {self.KEY: ("f64", self.VALUE)})

def test_valid(
self,
Expand All @@ -228,9 +218,7 @@ def test_valid(
version: str,
) -> None:
if version == "cpp":
pytest.xfail(
reason="https://github.com/eclipse-score/persistency/issues/182"
)
pytest.xfail(reason="https://github.com/eclipse-score/persistency/issues/182")
assert results.return_code == ResultCode.SUCCESS

logs = logs_info_level.get_logs("key", value=self.KEY)
Expand Down Expand Up @@ -273,9 +261,7 @@ def test_valid(
]
)
@pytest.mark.FullyVerifies([])
@pytest.mark.Description(
"Verifies that KVS fails to open when the defaults file contains invalid JSON."
)
@pytest.mark.Description("Verifies that KVS fails to open when the defaults file contains invalid JSON.")
@pytest.mark.TestType("requirements-based")
@pytest.mark.DerivationTechnique("requirements-based")
@pytest.mark.parametrize("defaults", ["optional", "required"], scope="class")
Expand Down Expand Up @@ -344,9 +330,7 @@ def test_invalid(
]
)
@pytest.mark.FullyVerifies([])
@pytest.mark.Description(
"Verifies that KVS fails to open when the defaults file is missing."
)
@pytest.mark.Description("Verifies that KVS fails to open when the defaults file is missing.")
@pytest.mark.TestType("requirements-based")
@pytest.mark.DerivationTechnique("requirements-based")
@pytest.mark.parametrize("defaults", ["required"], scope="class")
Expand Down Expand Up @@ -383,9 +367,7 @@ def test_invalid(self, results: ScenarioResult) -> None:
]
)
@pytest.mark.FullyVerifies(["comp_req__persistency__value_reset_v2"])
@pytest.mark.Description(
"Checks that resetting KVS restores all keys to their default values."
)
@pytest.mark.Description("Checks that resetting KVS restores all keys to their default values.")
@pytest.mark.TestType("requirements-based")
@pytest.mark.DerivationTechnique("requirements-based")
@pytest.mark.parametrize("defaults", ["optional", "required"], scope="class")
Expand Down Expand Up @@ -424,9 +406,7 @@ def test_valid(
version: str,
):
if version == "cpp":
pytest.xfail(
reason="https://github.com/eclipse-score/persistency/issues/182"
)
pytest.xfail(reason="https://github.com/eclipse-score/persistency/issues/182")
assert defaults_file is not None
assert results.return_code == ResultCode.SUCCESS

Expand All @@ -453,9 +433,7 @@ def test_valid(
]
)
@pytest.mark.FullyVerifies([])
@pytest.mark.Description(
"Checks that resetting single key restores it to its default value."
)
@pytest.mark.Description("Checks that resetting single key restores it to its default value.")
@pytest.mark.TestType("requirements-based")
@pytest.mark.DerivationTechnique("requirements-based")
@pytest.mark.parametrize("defaults", ["optional", "required"], scope="class")
Expand Down Expand Up @@ -495,9 +473,7 @@ def test_valid(
version: str,
):
if version == "cpp":
pytest.xfail(
reason="https://github.com/eclipse-score/persistency/issues/182"
)
pytest.xfail(reason="https://github.com/eclipse-score/persistency/issues/182")
assert defaults_file is not None
assert results.return_code == ResultCode.SUCCESS

Expand Down Expand Up @@ -538,9 +514,7 @@ def test_valid(
]
)
@pytest.mark.FullyVerifies(["comp_req__persistency__default_val_chksum_v2"])
@pytest.mark.Description(
"Ensures that a checksum file is created when opening KVS with defaults."
)
@pytest.mark.Description("Ensures that a checksum file is created when opening KVS with defaults.")
@pytest.mark.TestType("requirements-based")
@pytest.mark.DerivationTechnique("requirements-based")
@pytest.mark.parametrize("defaults", ["optional", "required"], scope="class")
Expand Down Expand Up @@ -568,9 +542,7 @@ def defaults_file(self, temp_dir: Path, defaults: str) -> Path | None:
if defaults == "without":
return None

return create_defaults_file(
temp_dir, self.instance_id(), {self.KEY: ("f64", self.VALUE)}
)
return create_defaults_file(temp_dir, self.instance_id(), {self.KEY: ("f64", self.VALUE)})

def test_valid(
self,
Expand Down
8 changes: 2 additions & 6 deletions tests/test_cases/tests/test_cit_multiple_kvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ def scenario_name(self) -> str:
@pytest.fixture(scope="class")
def test_config(self, temp_dir: Path) -> dict[str, Any]:
return {
"kvs_parameters_1": {
"kvs_parameters": {"instance_id": 1, "dir": str(temp_dir)}
},
"kvs_parameters_2": {
"kvs_parameters": {"instance_id": 2, "dir": str(temp_dir)}
},
"kvs_parameters_1": {"kvs_parameters": {"instance_id": 1, "dir": str(temp_dir)}},
"kvs_parameters_2": {"kvs_parameters": {"instance_id": 2, "dir": str(temp_dir)}},
}

def test_ok(self, results: ScenarioResult, logs_info_level: LogContainer):
Expand Down
Loading
Loading