-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MAINTENANCE] Refactor tests and add tests for private class `_Elemen…
…t` (#85)
- Loading branch information
1 parent
74c8592
commit 9e10713
Showing
19 changed files
with
76 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,28 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass(init=False, frozen=True, order=False, eq=False) | ||
class _Element: | ||
"""Base class for elements.""" | ||
|
||
@staticmethod | ||
def name() -> str: | ||
"""Shortcut for the class name.""" | ||
return __class__.__name__ | ||
|
||
def rep(self) -> str: | ||
"""Shortcut for `__repr__()`.""" | ||
return self.__repr__() | ||
|
||
def typename(self) -> str: | ||
"""Shortcut for the name of the class type. | ||
:return: The name of the class type. | ||
:rtype: str | ||
:example: | ||
>>> from symmetria import Cycle, CycleDecomposition, Permutation | ||
... | ||
>>> Permutation(1, 2, 3).typename() | ||
'Permutation' | ||
>>> Cycle(1, 2).typename() | ||
'Cycle' | ||
>>> CycleDecomposition(Cycle(1, 3, 2)).typename() | ||
'CycleDecomposition' | ||
""" | ||
return self.__class__.__name__ |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pytest | ||
|
||
from symmetria import Cycle, Permutation, CycleDecomposition | ||
from tests.test_utils import _check_values | ||
from symmetria.elements._base import _Element | ||
|
||
|
||
@pytest.mark.parametrize( | ||
argnames="expression, evaluation, expected", | ||
argvalues=[ | ||
("_element.name()", _Element().typename(), "_Element"), | ||
("Permutation(1).name()", Permutation(1).typename(), "Permutation"), | ||
("Cycle(1).name()", Cycle(1).typename(), "Cycle"), | ||
("CycleDecomposition(Cycle(1)).name()", CycleDecomposition(Cycle(1)).typename(), "CycleDecomposition"), | ||
], | ||
) | ||
def test_name(expression, evaluation, expected) -> None: | ||
_check_values(expression=expression, evaluation=evaluation, expected=expected) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
argnames="expression, evaluation, expected", | ||
argvalues=[ | ||
("_element.rep()", _Element().rep(), "_Element()"), | ||
("Permutation(1).rep()", Permutation(1).rep(), Permutation(1).__repr__()), | ||
("Cycle(1).rep()", Cycle(1).rep(), Cycle(1).__repr__()), | ||
( | ||
"CycleDecomposition(Cycle(1)).rep()", | ||
CycleDecomposition(Cycle(1)).rep(), | ||
CycleDecomposition(Cycle(1)).__repr__(), | ||
), | ||
], | ||
) | ||
def test_rep(expression, evaluation, expected) -> None: | ||
_check_values(expression=expression, evaluation=evaluation, expected=expected) |
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
tests/tests_cycle/test_constructors.py → ...elements/tests_cycle/test_constructors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
tests/tests_cycle/test_generic_method.py → ...ements/tests_cycle/test_generic_method.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
..._cycle_decomposition/test_constructors.py → ..._cycle_decomposition/test_constructors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...cle_decomposition/test_generic_methods.py → ...cle_decomposition/test_generic_methods.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
tests/tests_permutation/test_constructors.py → ...ts/tests_permutation/test_constructors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...tests_permutation/test_generic_methods.py → ...tests_permutation/test_generic_methods.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters