diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2021-03-02 17:48:20 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2021-03-02 17:48:20 +0100 |
| commit | 8fe33b3a8b61682e7a9abc7a97264d08eba7504b (patch) | |
| tree | e2204a81c13916331f145d7dd4e78110d524fbca /tests/test_hooks.py | |
| parent | 7cbaf473ca385cd64978a2d6f25f2df6af76bdb9 (diff) | |
| download | minishell_test-8fe33b3a8b61682e7a9abc7a97264d08eba7504b.tar.gz minishell_test-8fe33b3a8b61682e7a9abc7a97264d08eba7504b.tar.bz2 minishell_test-8fe33b3a8b61682e7a9abc7a97264d08eba7504b.zip | |
Added Result and ResultLeak tests
Diffstat (limited to 'tests/test_hooks.py')
| -rw-r--r-- | tests/test_hooks.py | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/tests/test_hooks.py b/tests/test_hooks.py index a811e55..2593b6e 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -6,12 +6,10 @@ # By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2021/02/27 20:03:52 by cacharle #+# #+# # -# Updated: 2021/02/28 12:05:58 by cacharle ### ########.fr # +# Updated: 2021/03/02 17:45:15 by cacharle ### ########.fr # # # # ############################################################################ # -import contextlib - from minishell_test.config import Config from minishell_test.hooks import ( @@ -28,17 +26,10 @@ from minishell_test.hooks import ( DISCARDED_TEXT, ) -Config.init([]) +from tests.helpers import config_context -@contextlib.contextmanager -def config_context(attr, value): - prev = getattr(Config, attr) - setattr(Config, attr, value) - try: - yield - finally: - setattr(Config, attr, prev) +Config.init([]) def test_sort_lines(): @@ -116,7 +107,7 @@ declare -x YSU_VERSION="1.7.3" declare -x ZDOTDIR="/home/cacharle/.config/zsh"\ """) - with config_context("shell_reference_args", ["--posix"]): + with config_context(shell_reference_args=["--posix"]): assert "" == export_singleton("export IGOTNUMBERS42") assert "" == export_singleton("export IGOTUNDERSCORE__") assert "" == export_singleton("export I") @@ -165,31 +156,31 @@ def test_should_not_be(): def test_platform_status(): - with config_context('platform', 'darwin'): + with config_context(platform='darwin'): assert 0 == platform_status(0, 1)(0) assert 1 == platform_status(42, 42)(1) - with config_context('platform', 'linux'): + with config_context(platform='linux'): assert 0 == platform_status(0, 1)(1) assert 42 == platform_status(0, 1)(42) - with config_context('platform', 'foo'): + with config_context(platform='foo'): assert 0 == platform_status(42, 42)(0) def test_linux_replace(): - with config_context('platform', 'darwin'): + with config_context(platform='darwin'): assert "Is a directory" == linux_replace("Is a directory", "is a directory")("Is a directory") assert "SHLVL=0" == linux_replace("SHLVL=0", "SHLVL=1")("SHLVL=0") assert "\\" == linux_replace("\\", "")("\\") - with config_context('platform', 'linux'): + with config_context(platform='linux'): assert "is a directory" == linux_replace("Is a directory", "is a directory")("Is a directory") assert "SHLVL=1" == linux_replace("SHLVL=0", "SHLVL=1")("SHLVL=0") assert "" == linux_replace("\\", "")("\\") def test_linux_discard(): - with config_context('platform', 'darwin'): + with config_context(platform='darwin'): assert "" == linux_discard("") assert "foo" == linux_discard("foo") - with config_context('platform', 'linux'): + with config_context(platform='linux'): assert DISCARDED_TEXT == linux_discard("") assert DISCARDED_TEXT == linux_discard("foo") |
