aboutsummaryrefslogtreecommitdiff
path: root/tests/test/test_result.py
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2021-03-02 14:33:51 +0100
committerCharles Cabergs <me@cacharle.xyz>2021-03-02 14:33:51 +0100
commit7cbaf473ca385cd64978a2d6f25f2df6af76bdb9 (patch)
tree4110ad8e2e88dfd5b285fe4c4727f348b2b58f3b /tests/test/test_result.py
parentaa79c9db6674deb205c7741e11d5520c76217b8d (diff)
downloadminishell_test-7cbaf473ca385cd64978a2d6f25f2df6af76bdb9.tar.gz
minishell_test-7cbaf473ca385cd64978a2d6f25f2df6af76bdb9.tar.bz2
minishell_test-7cbaf473ca385cd64978a2d6f25f2df6af76bdb9.zip
Refactoring test.result.Result
Diffstat (limited to 'tests/test/test_result.py')
-rw-r--r--tests/test/test_result.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/test/test_result.py b/tests/test/test_result.py
new file mode 100644
index 0000000..35c6213
--- /dev/null
+++ b/tests/test/test_result.py
@@ -0,0 +1,82 @@
+# ############################################################################ #
+# #
+# ::: :::::::: #
+# test_result.py :+: :+: :+: #
+# +:+ +:+ +:+ #
+# By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ #
+# +#+#+#+#+#+ +#+ #
+# Created: 2021/03/01 16:26:34 by cacharle #+# #+# #
+# Updated: 2021/03/02 14:21:14 by cacharle ### ########.fr #
+# #
+# ############################################################################ #
+
+import pytest
+
+from minishell_test.config import Config
+from minishell_test import colors
+
+colors.disable()
+Config.init([])
+
+from minishell_test.test.result import BaseResult, Result, LeakResult
+from minishell_test.test.captured import CapturedCommand
+
+
+class TestBaseResult:
+ @pytest.fixture
+ def base_result(self):
+ return BaseResult("echo bonjour")
+
+ def test_passed(self, base_result):
+ with pytest.raises(NotImplementedError):
+ base_result.passed
+
+ def test_failed(self, base_result):
+ with pytest.raises(NotImplementedError):
+ base_result.failed
+
+ def test_repr(self, base_result):
+ with pytest.raises(NotImplementedError):
+ base_result.__repr__()
+
+ def test_cmd(self, base_result):
+ assert "echo bonjour" == base_result._cmd
+ assert "foo\\nbar" == BaseResult("foo\nbar")._cmd
+ assert "foo\\tbar" == BaseResult("foo\tbar")._cmd
+ assert "foo\\vbar" == BaseResult("foo\vbar")._cmd
+ assert "foo\\rbar" == BaseResult("foo\rbar")._cmd
+ assert "foo\\fbar" == BaseResult("foo\fbar")._cmd
+
+ def test_summarize(self, base_result):
+ pass
+
+
+
+
+class TestResult:
+ @pytest.fixture
+ def result_pass(self):
+ return Result(
+ "echo bonjour",
+ [],
+ CapturedCommand("bonjour", 0, []),
+ CapturedCommand("bonjour", 0, []),
+ )
+
+ @pytest.fixture
+ def result_fail(self):
+ return Result(
+ "echo bonjour",
+ [],
+ CapturedCommand("bonjour", 0, []),
+ CapturedCommand("aurevoir", 0, []),
+ )
+
+ def test_passed(self, result_pass, result_fail):
+ assert result_pass.passed
+ assert not result_fail.passed
+
+ def test_failed(self, result_pass, result_fail):
+ assert not result_pass.failed
+ assert result_fail.failed
+