aboutsummaryrefslogtreecommitdiff
path: root/minishell_test/test
diff options
context:
space:
mode:
Diffstat (limited to 'minishell_test/test')
-rw-r--r--minishell_test/test/__init__.py4
-rw-r--r--minishell_test/test/captured.py10
-rw-r--r--minishell_test/test/result.py24
-rw-r--r--minishell_test/test/test.py34
4 files changed, 36 insertions, 36 deletions
diff --git a/minishell_test/test/__init__.py b/minishell_test/test/__init__.py
index cf9949f..534da32 100644
--- a/minishell_test/test/__init__.py
+++ b/minishell_test/test/__init__.py
@@ -6,8 +6,8 @@
# By: charles <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/09/11 12:18:14 by charles #+# #+# #
-# Updated: 2020/09/11 20:18:10 by charles ### ########.fr #
+# Updated: 2021/02/05 14:42:47 by charles ### ########.fr #
# #
# ############################################################################ #
-from test.test import Test # noqa: F401
+from minishell_test.test.test import Test # noqa: F401
diff --git a/minishell_test/test/captured.py b/minishell_test/test/captured.py
index f7dae3e..7db9739 100644
--- a/minishell_test/test/captured.py
+++ b/minishell_test/test/captured.py
@@ -6,13 +6,13 @@
# By: charles <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/09/11 12:16:25 by charles #+# #+# #
-# Updated: 2021/02/04 15:52:19 by charles ### ########.fr #
+# Updated: 2021/02/05 17:47:10 by charles ### ########.fr #
# #
# ############################################################################ #
from typing import List, Optional
-import config
+import minishell_test.config as config
class Captured:
@@ -46,9 +46,9 @@ class Captured:
raise NotImplementedError
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)))
+ 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():
diff --git a/minishell_test/test/result.py b/minishell_test/test/result.py
index eff7b8b..9769527 100644
--- a/minishell_test/test/result.py
+++ b/minishell_test/test/result.py
@@ -6,7 +6,7 @@
# By: charles <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/09/11 12:17:34 by charles #+# #+# #
-# Updated: 2021/02/05 01:36:44 by charles ### ########.fr #
+# Updated: 2021/02/05 17:46:30 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -14,8 +14,8 @@ import sys
import re
from typing import Match, List, Optional
-import config
-from test.captured import Captured
+import minishell_test.config as config
+from minishell_test.test.captured import Captured
class BaseResult:
@@ -168,11 +168,11 @@ class Result(BaseResult):
return ""
file_header = self.indicator("FILE {}".format(file_name), "|#") + '\n'
return (
- file_header
- + self.expected_header
- + self.cat_e(expected)
- + self.actual_header
- + self.cat_e(actual)
+ file_header +
+ self.expected_header +
+ self.cat_e(expected) +
+ self.actual_header +
+ self.cat_e(actual)
)
def files_diff(self):
@@ -194,10 +194,10 @@ class Result(BaseResult):
.format(self.expected.status, self.actual.status), "| "
) + '\n'
if self.expected.output != self.actual.output:
- out += (self.expected_header
- + self.cat_e(self.expected.output)
- + self.actual_header
- + self.cat_e(self.actual.output))
+ out += (self.expected_header +
+ self.cat_e(self.expected.output) +
+ self.actual_header +
+ self.cat_e(self.actual.output))
return out
def full_diff(self) -> str:
diff --git a/minishell_test/test/test.py b/minishell_test/test/test.py
index ab68d1e..ff1f389 100644
--- a/minishell_test/test/test.py
+++ b/minishell_test/test/test.py
@@ -6,7 +6,7 @@
# By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/06/16 21:48:50 by charles #+# #+# #
-# Updated: 2021/02/05 01:37:44 by charles ### ########.fr #
+# Updated: 2021/02/05 18:35:12 by charles ### ########.fr #
# #
# ############################################################################ #
@@ -15,12 +15,12 @@ import sys
import subprocess
from typing import Optional, List, Dict, Union, Callable
-import config
-from test.captured import Captured
-from test.result import Result, LeakResult
-import sandbox
+import minishell_test.config as config
+from minishell_test.test.captured import Captured
+from minishell_test.test.result import Result, LeakResult
+import minishell_test.sandbox as sandbox
-HookType = Union[Callable[[str], str], List[Callable[[str], str]]]
+HookType = Union[Callable[[str], str], List[Callable[[str], str]]]
HookStatusType = Union[Callable[[int], int], List[Callable[[int], int]]]
@@ -28,11 +28,11 @@ class Test:
def __init__(
self,
cmd: str,
- setup: str = "",
- files: List[str] = [],
- exports: Dict[str, str] = {},
- timeout: float = config.TIMEOUT,
- hook: HookType = [],
+ setup: str = "",
+ files: List[str] = [],
+ exports: Dict[str, str] = {},
+ timeout: float = config.TIMEOUT,
+ hook: HookType = [],
hook_status: HookStatusType = [],
):
""" Test class
@@ -50,12 +50,12 @@ class Test:
self.exports = exports
self.result: Optional[Union[Result, LeakResult]] = None
self.timeout = timeout
- if type(hook) is not list:
- hook = [hook] # type: ignore
- if type(hook_status) is not list:
- hook_status = [hook_status] # type: ignore
- self.hook: List[Callable[[str], str]] = hook # type: ignore
- self.hook_status: List[Callable[[int], int]] = hook_status # type: ignore
+ if not isinstance(hook, list):
+ hook = [hook]
+ if not isinstance(hook_status, list):
+ hook_status = [hook_status]
+ self.hook = hook
+ self.hook_status = hook_status
def run(self, index: int) -> None:
""" Run the test for minishell and the reference shell and print the result out """