Skip to content

Commit

Permalink
test: correct implementation of the get_matrix_id mock
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent-laporte-pro committed Mar 25, 2024
1 parent 70dc017 commit dc0e93f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion tests/variantstudy/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ def get_matrix_id(matrix: t.Union[t.List[t.List[float]], str]) -> str:
Get the matrix ID from a matrix or a matrix link.
"""
if isinstance(matrix, str):
return matrix.lstrip("matrix://")
# str.removeprefix() is not available in Python 3.8
prefix = "matrix://"
if matrix.startswith(prefix):
return matrix[len(prefix) :]
return matrix
elif isinstance(matrix, list):
return create(matrix)
else:
Expand Down
6 changes: 5 additions & 1 deletion tests/variantstudy/test_command_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,11 @@ def setup_class(self):
@pytest.mark.unit_test
def test_command_factory(self, command_dto: CommandDTO):
def get_matrix_id(matrix: str) -> str:
return matrix.lstrip("matrix://")
# str.removeprefix() is not available in Python 3.8
prefix = "matrix://"
if matrix.startswith(prefix):
return matrix[len(prefix) :]
return matrix

command_factory = CommandFactory(
generator_matrix_constants=Mock(spec=GeneratorMatrixConstants),
Expand Down

0 comments on commit dc0e93f

Please sign in to comment.