diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2021-03-01 16:26:03 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2021-03-01 16:26:03 +0100 |
| commit | aa79c9db6674deb205c7741e11d5520c76217b8d (patch) | |
| tree | 35de4f9eedaf310f83074f74c8c6444480606748 | |
| parent | 6848c33412a4f57ae4de6a05d27a5b767ce89fe1 (diff) | |
| download | minishell_test-aa79c9db6674deb205c7741e11d5520c76217b8d.tar.gz minishell_test-aa79c9db6674deb205c7741e11d5520c76217b8d.tar.bz2 minishell_test-aa79c9db6674deb205c7741e11d5520c76217b8d.zip | |
Added tests for test/captured
| -rw-r--r-- | README.md | 12 | ||||
| -rw-r--r-- | docs/README.rst | 4 | ||||
| -rw-r--r-- | docs/gettingstarted.rst.inc | 2 | ||||
| -rw-r--r-- | minishell_test/test/captured.py | 7 | ||||
| -rw-r--r-- | tests/test/test_captured.py | 50 |
5 files changed, 61 insertions, 14 deletions
@@ -6,6 +6,11 @@  +## Documentation + +The full documentation for this project is available at +[minishell-test.readthedocs.io](https://minishell-test.readthedocs.io). + ## Getting Started ### Installation @@ -18,7 +23,7 @@ $ pip3 install --user minishell-test # if you don't have root access ### Compatibility Your executable **must** support the `-c` option which allow to pass -command as string. +command as an argument. ``` $ bash -c 'echo bonjour je suis | cat -e' @@ -61,8 +66,3 @@ If you get `command not found`, do either of those things: - Run `$ python3 -m minishell_test` instead of `$ minishell_test` </div> - -## Documentation - -The full documentation for this project is available at -[minishell-test.readthedocs.io](https://minishell-test.readthedocs.io). diff --git a/docs/README.rst b/docs/README.rst index 6609610..54c0f31 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -16,9 +16,9 @@ minishell_test .. image:: https://i.imgur.com/98xh2xY.gif :alt: preview -.. include:: gettingstarted.rst.inc - Documentation ------------- The full documentation for this project is available at `minishell-test.readthedocs.io <https://minishell-test.readthedocs.io>`_. + +.. include:: gettingstarted.rst.inc diff --git a/docs/gettingstarted.rst.inc b/docs/gettingstarted.rst.inc index f1dce9c..1293f66 100644 --- a/docs/gettingstarted.rst.inc +++ b/docs/gettingstarted.rst.inc @@ -19,7 +19,7 @@ Your executable **must** support the ``-c`` option which allow to pass command a .. code-block:: $ bash -c 'echo bonjour je suis | cat -e' - bonjour he suis$ + bonjour je suis$ $ ./minishell -c 'echo bonjour je suis | cat -e' bonjour je suis$ diff --git a/minishell_test/test/captured.py b/minishell_test/test/captured.py index c55b38e..6481dcf 100644 --- a/minishell_test/test/captured.py +++ b/minishell_test/test/captured.py @@ -6,15 +6,12 @@ # By: charles <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/09/11 12:16:25 by charles #+# #+# # -# Updated: 2021/03/01 16:02:26 by cacharle ### ########.fr # +# Updated: 2021/03/01 16:15:31 by cacharle ### ########.fr # # # # ############################################################################ # -import re from typing import List, Optional -from minishell_test.config import Config - class Captured: def __init__( @@ -38,7 +35,7 @@ class Captured: def __eq__(self, other: object) -> bool: if not isinstance(other, Captured): - raise NotImplementedError + return False if self.is_timeout: return self.is_timeout == other.is_timeout return (self.output == other.output and diff --git a/tests/test/test_captured.py b/tests/test/test_captured.py new file mode 100644 index 0000000..2c085c6 --- /dev/null +++ b/tests/test/test_captured.py @@ -0,0 +1,50 @@ +# ############################################################################ # +# # +# ::: :::::::: # +# test_captured.py :+: :+: :+: # +# +:+ +:+ +:+ # +# By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2021/03/01 15:55:11 by cacharle #+# #+# # +# Updated: 2021/03/01 16:19:23 by cacharle ### ########.fr # +# # +# ############################################################################ # + +import pytest +import copy + +from minishell_test.test.captured import Captured + + +@pytest.fixture +def captured(): + return Captured("foo", 0, ["file1", "file2"], False) + + +def test_init(captured): + assert "foo" == captured.output + assert 0 == captured.status + assert ["file1", "file2"] == captured.files_content + assert not captured.is_timeout + + +def test_eq(captured): + assert captured != 42 + assert captured != "bonjour" + assert captured == captured + c2 = copy.deepcopy(captured) + assert captured == c2 + c2.output = "bar" + assert captured != c2 + c2 = copy.deepcopy(captured) + c2.status = 42 + assert captured != c2 + c2 = copy.deepcopy(captured) + c2.files_content = ["asdfasdf"] + assert captured != c2 + assert captured != Captured.timeout() + assert Captured.timeout() == Captured.timeout() + + +def test_timeout(): + assert Captured.timeout().is_timeout |
