diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2021-01-31 03:36:45 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2021-01-31 03:36:45 +0100 |
| commit | aa962c545496fc645d3f78370d7190ae1f3db11e (patch) | |
| tree | cadd291fcf24ec6fe222e2ce204135ce3ea88828 /src | |
| parent | 4a4f6b5b01bd6d23c141d51dd9399c36d12d29d9 (diff) | |
| download | minishell_test-aa962c545496fc645d3f78370d7190ae1f3db11e.tar.gz minishell_test-aa962c545496fc645d3f78370d7190ae1f3db11e.tar.bz2 minishell_test-aa962c545496fc645d3f78370d7190ae1f3db11e.zip | |
Fixing type annotation for python3.6 compatibility
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.py | 5 | ||||
| -rw-r--r-- | src/suite/suite.py | 14 | ||||
| -rw-r--r-- | src/test/captured.py | 6 | ||||
| -rw-r--r-- | src/test/result.py | 7 | ||||
| -rw-r--r-- | src/test/test.py | 12 |
5 files changed, 24 insertions, 20 deletions
diff --git a/src/config.py b/src/config.py index 95600c6..075f2be 100644 --- a/src/config.py +++ b/src/config.py @@ -6,7 +6,7 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:19 by charles #+# #+# # -# Updated: 2021/01/31 01:59:00 by charles ### ########.fr # +# Updated: 2021/01/31 03:29:05 by charles ### ########.fr # # # # ############################################################################ # @@ -17,6 +17,7 @@ import os import shutil import distutils.spawn +from typing import List # run the bonus tests # can be changed with `export MINISHELL_TEST_BONUS=yes` in your shell rc file. @@ -35,7 +36,7 @@ MINISHELL_MAKE = True # has to support the -c option (sh, bash and zsh support it) REFERENCE_PATH = "/bin/bash" # can be changed with `export MINISHELL_TEST_ARGS=--poxix,--otherarg` -REFERENCE_ARGS: list[str] = [] # ["--posix"] +REFERENCE_ARGS: List[str] = [] # ["--posix"] # pager to use with --pager option # can be changed with `export MINISHELL_TEST_PAGER=yourpager` diff --git a/src/suite/suite.py b/src/suite/suite.py index 6acdd27..ef01784 100644 --- a/src/suite/suite.py +++ b/src/suite/suite.py @@ -6,19 +6,19 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/07/15 18:24:29 by charles #+# #+# # -# Updated: 2021/01/31 02:24:35 by charles ### ########.fr # +# Updated: 2021/01/31 03:31:15 by charles ### ########.fr # # # # ############################################################################ # import sys -from typing import List +from typing import List, Tuple import config from test import Test class Suite: - available: list['Suite'] = [] + available: List['Suite'] = [] @classmethod def run_all(cls): @@ -28,7 +28,7 @@ class Suite: break @classmethod - def setup(cls, asked_names: list[str]): + def setup(cls, asked_names: List[str]): """ Remove not asked suite from available suites Tries to autocomplete the asked names """ @@ -71,7 +71,7 @@ class Suite: s.generator_func() @classmethod - def available_names(cls) -> list[str]: + def available_names(cls) -> List[str]: """List of available suites names""" return [s.name for s in cls.available] @@ -108,7 +108,7 @@ class Suite: self.description = description self.bonus = bonus self.generator_func = None - self.tests: list[Test] = [] + self.tests: List[Test] = [] def add(self, test): """Append a test to the suite""" @@ -139,7 +139,7 @@ class Suite: print() return True - def total(self) -> tuple[int, int]: + def total(self) -> Tuple[int, int]: """Returns the total of passed and failed tests""" passed_total = 0 for t in self.tests: diff --git a/src/test/captured.py b/src/test/captured.py index 9488149..2c33b78 100644 --- a/src/test/captured.py +++ b/src/test/captured.py @@ -6,15 +6,17 @@ # By: charles <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 12:16:25 by charles #+# #+# # -# Updated: 2021/01/31 02:01:30 by charles ### ########.fr # +# Updated: 2021/01/31 03:29:22 by charles ### ########.fr # # # # ############################################################################ # +from typing import List + import config class Captured: - def __init__(self, output: str, status: int, files_content: list[str], is_timeout: bool = False): + def __init__(self, output: str, status: int, files_content: List[str], is_timeout: bool = False): """Captured class output: captured content status: command status diff --git a/src/test/result.py b/src/test/result.py index 3cc268d..4d060fa 100644 --- a/src/test/result.py +++ b/src/test/result.py @@ -6,18 +6,19 @@ # By: charles <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 12:17:34 by charles #+# #+# # -# Updated: 2021/01/31 02:28:58 by charles ### ########.fr # +# Updated: 2021/01/31 03:35:53 by charles ### ########.fr # # # # ############################################################################ # import sys import re -from typing import Match +from typing import Match, List import config from test.captured import Captured +# TODO split into BaseResult, Result and LeakResult class Result: RED_CHARS = "\033[31m" GREEN_CHARS = "\033[32m" @@ -28,7 +29,7 @@ class Result: def __init__( self, cmd: str, - file_names: list[str], + file_names: List[str], expected: Captured, actual: Captured, leak_output: str = None diff --git a/src/test/test.py b/src/test/test.py index 527b435..517e610 100644 --- a/src/test/test.py +++ b/src/test/test.py @@ -6,14 +6,14 @@ # By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/06/16 21:48:50 by charles #+# #+# # -# Updated: 2021/01/31 02:21:17 by charles ### ########.fr # +# Updated: 2021/01/31 03:30:15 by charles ### ########.fr # # # # ############################################################################ # import os import sys import subprocess -from typing import Optional +from typing import Optional, List, Dict import config from test.captured import Captured @@ -25,8 +25,8 @@ class Test: def __init__(self, cmd: str, setup: str = "", - files: list[str] = [], - exports: dict[str, str] = {}, + files: List[str] = [], + exports: Dict[str, str] = {}, timeout: float = config.TIMEOUT, signal=None, hook=[], @@ -73,7 +73,7 @@ class Test: self.result = Result(self.full_cmd, self.files, expected, actual) self.result.put(index) - def _run_sandboxed(self, shell_cmd: list[str]) -> Captured: + def _run_sandboxed(self, shell_cmd: List[str]) -> Captured: """ Run the command in a sandbox environment """ with sandbox.context(): if self.setup != "": @@ -95,7 +95,7 @@ class Test: sys.exit(1) return self._run_capture(shell_cmd) - def _run_capture(self, shell_cmd: list[str]) -> Captured: + def _run_capture(self, shell_cmd: List[str]) -> Captured: """ Capture the output (stdout and stderr) Capture the content of the watched files after the command is run """ |
