diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2021-03-02 14:33:51 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2021-03-02 14:33:51 +0100 |
| commit | 7cbaf473ca385cd64978a2d6f25f2df6af76bdb9 (patch) | |
| tree | 4110ad8e2e88dfd5b285fe4c4727f348b2b58f3b /minishell_test/test/captured.py | |
| parent | aa79c9db6674deb205c7741e11d5520c76217b8d (diff) | |
| download | minishell_test-7cbaf473ca385cd64978a2d6f25f2df6af76bdb9.tar.gz minishell_test-7cbaf473ca385cd64978a2d6f25f2df6af76bdb9.tar.bz2 minishell_test-7cbaf473ca385cd64978a2d6f25f2df6af76bdb9.zip | |
Refactoring test.result.Result
Diffstat (limited to 'minishell_test/test/captured.py')
| -rw-r--r-- | minishell_test/test/captured.py | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/minishell_test/test/captured.py b/minishell_test/test/captured.py index 6481dcf..bb09579 100644 --- a/minishell_test/test/captured.py +++ b/minishell_test/test/captured.py @@ -6,43 +6,49 @@ # By: charles <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 12:16:25 by charles #+# #+# # -# Updated: 2021/03/01 16:15:31 by cacharle ### ########.fr # +# Updated: 2021/03/02 10:32:19 by cacharle ### ########.fr # # # # ############################################################################ # -from typing import List, Optional +from typing import List, Optional, Union -class Captured: +class CapturedCommand: def __init__( self, output: str, status: int, files_content: List[Optional[str]], - is_timeout: bool = False ): - """Captured class - output: captured content - status: command status - files_content: content of the files altered by the command - is_timeout: the command has timed out + """Captured command + + :param output: + Command output + :param status: + Command return status code + :param files_content: + Content of the files altered by the command """ self.output = output self.status = status self.files_content = files_content - self.is_timeout = is_timeout def __eq__(self, other: object) -> bool: - if not isinstance(other, Captured): + if not isinstance(other, CapturedCommand): return False - if self.is_timeout: - return self.is_timeout == other.is_timeout - return (self.output == other.output and - self.status == other.status and - all(x == y for x, y in zip(self.files_content, other.files_content))) - - @staticmethod - def timeout(): - """Create a new captured timeout""" - return Captured("", 0, [], is_timeout=True) + return ( + self.output == other.output and + self.status == other.status and + all(x == y for x, y in zip(self.files_content, other.files_content)) + ) + + +class CapturedTimeout(): + """Captured timeout""" + + def __eq__(self, other: object) -> bool: + return isinstance(other, CapturedTimeout) + + +CapturedType = Union[CapturedCommand, CapturedTimeout] |
