diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | .travis.yml | 2 | ||||
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | docs/README.rst | 11 | ||||
| -rw-r--r-- | minishell_test/test/result.py | 2 | ||||
| -rw-r--r-- | requirements-dev.txt | 1 | ||||
| -rw-r--r-- | tests/test/test_result.py | 51 |
7 files changed, 56 insertions, 14 deletions
@@ -9,3 +9,5 @@ build/ docs/_build/ bash3.2.57 *.bak +.coverage +coverage.xml diff --git a/.travis.yml b/.travis.yml index 5c2486f..7bf128f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,3 +33,5 @@ script: - python -m pytest -vvv - python -m minishell_test -p /tmp/minishell - python -m minishell_test -p /tmp/minishell -k pwd + +after_succes: bash <(curl -s https://codecov.io/bash) @@ -3,6 +3,7 @@ [](https://pypi.org/project/minishell-test/) [](https://minishell-test.readthedocs.io) [](https://travis-ci.com/cacharle/minishell_test) +[](https://codecov.io/gh/cacharle/minishell_test)  diff --git a/docs/README.rst b/docs/README.rst index 54c0f31..1aa00b4 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -7,11 +7,14 @@ minishell_test .. |documentation-build| image:: https://readthedocs.org/projects/minishell-test/badge/?version=latest :alt: Documentation :target: https://minishell-test.readthedocs.io -.. |travis-build| image:: https://api.travis-ci.com/cacharle/minishell_test.svg?branch=master - :alt: Build Status - :target: https://travis-ci.com/cacharle/minishell_test +.. |travis-build| image:: https://api.travis-ci.com/cacharle/minishell_test.svg?branch=master + :alt: Build Status + :target: https://travis-ci.com/cacharle/minishell_test +.. |codecov| image:: https://codecov.io/gh/cacharle/minishell_test/branch/master/graph/badge.svg?token=NB9C6688R1 + :alt: Code coverage + :target: https://codecov.io/gh/cacharle/minishell_test -|pypi-python-version| |documentation-build| |travis-build| +|pypi-python-version| |documentation-build| |travis-build| |codecov| .. image:: https://i.imgur.com/98xh2xY.gif :alt: preview diff --git a/minishell_test/test/result.py b/minishell_test/test/result.py index 7936fb3..50b6845 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/03/02 17:44:02 by cacharle ### ########.fr # +# Updated: 2021/03/03 07:52:40 by cacharle ### ########.fr # # # # ############################################################################ # diff --git a/requirements-dev.txt b/requirements-dev.txt index d811531..23d706c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,6 +4,7 @@ flake8==3.8.4 flake8_comprehensions==3.3.1 pep8_naming==0.11.1 pytest +pytest-cov sphinx sphinx-rtd-theme sphinxcontrib-programoutput diff --git a/tests/test/test_result.py b/tests/test/test_result.py index 7b29f66..f64511a 100644 --- a/tests/test/test_result.py +++ b/tests/test/test_result.py @@ -6,7 +6,7 @@ # By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2021/03/01 16:26:34 by cacharle #+# #+# # -# Updated: 2021/03/02 17:47:59 by cacharle ### ########.fr # +# Updated: 2021/03/03 07:53:09 by cacharle ### ########.fr # # # # ############################################################################ # @@ -102,6 +102,15 @@ class TestResult: ) @pytest.fixture + def result_fail_file_not_exist_expected(self): + return Result( + "echo bonjour", + ["foo"], + CapturedCommand("bonjour", 0, [None]), + CapturedCommand("bonjour", 0, ["bonjour"]), + ) + + @pytest.fixture def result_fail_file_multiple(self): return Result( "echo bonjour > foo > bar", @@ -114,29 +123,37 @@ class TestResult: def result_fail_timeout(self): return Result("echo bonjour", [], CapturedCommand("bonjour", 0, []), CapturedTimeout()) - def test_passed(self, result_pass, result_fail, result_fail_status, - result_fail_file, result_fail_file_not_exist, result_fail_file_multiple, result_fail_timeout): + @pytest.fixture + def result_pass_long_cmd(self): + return Result("e" * 300, [], CapturedCommand("", 0, []), CapturedCommand("", 0, [])) + + def test_passed(self, result_pass, result_fail, result_fail_status, result_fail_file, result_fail_file_not_exist, + result_fail_file_multiple, result_fail_timeout, result_fail_file_not_exist_expected, result_pass_long_cmd): assert result_pass.passed + assert result_pass_long_cmd.passed assert not result_fail.passed assert not result_fail_status.passed assert not result_fail_file.passed assert not result_fail_file_not_exist.passed assert not result_fail_file_multiple.passed assert not result_fail_timeout.passed + assert not result_fail_file_not_exist_expected.passed - def test_failed(self, result_pass, result_fail, result_fail_status, - result_fail_file, result_fail_file_not_exist, result_fail_file_multiple, result_fail_timeout): + def test_failed(self, result_pass, result_fail, result_fail_status, result_fail_file, result_fail_file_not_exist, + result_fail_file_multiple, result_fail_timeout, result_fail_file_not_exist_expected, result_pass_long_cmd): assert not result_pass.failed + assert not result_pass_long_cmd.failed assert result_fail.failed assert result_fail_status.failed assert result_fail_file.failed assert result_fail_file_not_exist.failed assert result_fail_file_multiple.failed assert result_fail_timeout.failed + assert result_fail_file_not_exist_expected.failed @pytest.mark.parametrize("term_cols", range(40, 300, 40)) - def test_summarize(self, result_pass, result_fail, result_fail_status, - result_fail_file, result_fail_file_not_exist, result_fail_timeout, term_cols): + def test_summarize(self, result_pass, result_fail, result_fail_status, result_fail_file, result_fail_file_not_exist, + result_fail_timeout, result_fail_file_not_exist_expected, result_pass_long_cmd, term_cols): with config_context(show_range=False, term_cols=term_cols): assert f"{'echo bonjour':{term_cols - 7}} [PASS]" == result_pass.summarize(-1) assert f"{'echo bonjour':{term_cols - 7}} [FAIL]" == result_fail.summarize(-1) @@ -144,6 +161,8 @@ class TestResult: assert f"{'echo bonjour > foo':{term_cols - 7}} [FAIL]" == result_fail_file.summarize(-1) assert f"{'echo bonjour > foo':{term_cols - 7}} [FAIL]" == result_fail_file_not_exist.summarize(-1) assert f"{'echo bonjour':{term_cols - 7}} [FAIL]" == result_fail_timeout.summarize(-1) + assert f"{'echo bonjour':{term_cols - 7}} [FAIL]" == result_fail_file_not_exist_expected.summarize(-1) + assert f"{('e' * 300)[:term_cols - 10]}... [PASS]" == result_pass_long_cmd.summarize(-1) with config_context(show_range=True, term_cols=term_cols): assert f" 1: {'echo bonjour':{term_cols - 11}} [PASS]" == result_pass.summarize(1) assert f" 1: {'echo bonjour':{term_cols - 11}} [FAIL]" == result_fail.summarize(1) @@ -151,21 +170,27 @@ class TestResult: assert f" 1: {'echo bonjour > foo':{term_cols - 11}} [FAIL]" == result_fail_file.summarize(1) assert f" 1: {'echo bonjour > foo':{term_cols - 11}} [FAIL]" == result_fail_file_not_exist.summarize(1) assert f" 1: {'echo bonjour':{term_cols - 11}} [FAIL]" == result_fail_timeout.summarize(1) + assert f" 1: {'echo bonjour':{term_cols - 11}} [FAIL]" == result_fail_file_not_exist_expected.summarize(1) + assert f" 1: {('e' * 300)[:term_cols - 14]}... [PASS]" == result_pass_long_cmd.summarize(1) assert f"99: {'echo bonjour':{term_cols - 11}} [PASS]" == result_pass.summarize(99) assert f"99: {'echo bonjour':{term_cols - 11}} [FAIL]" == result_fail.summarize(99) assert f"99: {'echo bonjour':{term_cols - 11}} [FAIL]" == result_fail_status.summarize(99) assert f"99: {'echo bonjour > foo':{term_cols - 11}} [FAIL]" == result_fail_file.summarize(99) assert f"99: {'echo bonjour > foo':{term_cols - 11}} [FAIL]" == result_fail_file_not_exist.summarize(99) assert f"99: {'echo bonjour':{term_cols - 11}} [FAIL]" == result_fail_timeout.summarize(99) + assert f"99: {'echo bonjour':{term_cols - 11}} [FAIL]" == result_fail_file_not_exist_expected.summarize(99) + assert f"99: {('e' * 300)[:term_cols - 14]}... [PASS]" == result_pass_long_cmd.summarize(99) assert f"100: {'echo bonjour':{term_cols - 12}} [PASS]" == result_pass.summarize(100) assert f"100: {'echo bonjour':{term_cols - 12}} [FAIL]" == result_fail.summarize(100) assert f"100: {'echo bonjour':{term_cols - 12}} [FAIL]" == result_fail_status.summarize(100) assert f"100: {'echo bonjour > foo':{term_cols - 12}} [FAIL]" == result_fail_file.summarize(100) assert f"100: {'echo bonjour > foo':{term_cols - 12}} [FAIL]" == result_fail_file_not_exist.summarize(100) assert f"100: {'echo bonjour':{term_cols - 12}} [FAIL]" == result_fail_timeout.summarize(100) + assert f"100: {'echo bonjour':{term_cols - 12}} [FAIL]" == result_fail_file_not_exist_expected.summarize(100) + assert f"100: {('e' * 300)[:term_cols - 15]}... [PASS]" == result_pass_long_cmd.summarize(100) - def test_repr(self, result_fail, result_fail_status, result_fail_file, - result_fail_file_not_exist, result_fail_file_multiple, result_fail_timeout): + def test_repr(self, result_fail, result_fail_status, result_fail_file, result_fail_file_not_exist, result_fail_file_multiple, + result_fail_timeout, result_fail_file_not_exist_expected): assert """\ |> WITH echo bonjour |----------------------------------------EXPECTED------------------------------- @@ -209,6 +234,14 @@ FROM TEST: File not created |> WITH echo bonjour TIMEOUT """ == result_fail_timeout.__repr__() + assert """\ +|> WITH echo bonjour +|# FILE foo +|----------------------------------------EXPECTED------------------------------- +FROM TEST: File not created +|----------------------------------------ACTUAL--------------------------------- +bonjour +""" == result_fail_file_not_exist_expected.__repr__() def test_expected_is_timeout(self): with pytest.raises(RuntimeError): |
