aboutsummaryrefslogtreecommitdiff
path: root/src/test/captured.py
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-09-11 12:33:34 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-09-11 12:33:34 +0200
commit46ba2708f83bf46186c33bf84975d39e87f467c1 (patch)
tree8275c80bba98d63e81e3af9a1df8be62e0419003 /src/test/captured.py
parentc0b1a90cf9c52a0c9b1623ac695516031d5ccdba (diff)
downloadminishell_test-46ba2708f83bf46186c33bf84975d39e87f467c1.tar.gz
minishell_test-46ba2708f83bf46186c33bf84975d39e87f467c1.tar.bz2
minishell_test-46ba2708f83bf46186c33bf84975d39e87f467c1.zip
Refactoring files, splited test.py and suite.py in packages
Diffstat (limited to 'src/test/captured.py')
-rw-r--r--src/test/captured.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/captured.py b/src/test/captured.py
new file mode 100644
index 0000000..e47590b
--- /dev/null
+++ b/src/test/captured.py
@@ -0,0 +1,39 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# captured.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# By: charles <me@cacharle.xyz> +#+ +:+ +#+ #
+# +#+#+#+#+#+ +#+ #
+# Created: 2020/09/11 12:16:25 by charles #+# #+# #
+# Updated: 2020/09/11 12:16:51 by charles ### ########.fr #
+# #
+# ############################################################################ #
+
+import config
+
+class Captured:
+ def __init__(self, output: str, status: int, files_content: [str], is_timeout: bool = False):
+ lines = output.split('\n')
+ for i, l in enumerate(lines):
+ if l.find(config.REFERENCE_ERROR_BEGIN) == 0:
+ lines[i] = l.replace(config.REFERENCE_ERROR_BEGIN, config.MINISHELL_ERROR_BEGIN, 1)
+ elif l.find(config.REFERENCE_PATH + ": ") == 0:
+ lines[i] = l.replace(config.REFERENCE_PATH + ": ", config.MINISHELL_ERROR_BEGIN, 1)
+
+ self.output = '\n'.join(lines)
+
+ self.status = status
+ self.files_content = files_content
+ self.is_timeout = is_timeout
+
+ def __eq__(self, other: 'Result') -> bool:
+ 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():
+ return Captured("", 0, [], is_timeout = True)