From b6eb06aeee0fda77395d7b3172c44b999b70cdee Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sun, 28 Feb 2021 11:04:52 +0100 Subject: Refactoring config in a class to have a testable environment --- minishell_test/suites/builtin.py | 8 ++++---- minishell_test/suites/cmd.py | 6 +++--- minishell_test/suites/flow.py | 18 +++++++++--------- minishell_test/suites/preprocess.py | 8 ++++---- 4 files changed, 20 insertions(+), 20 deletions(-) (limited to 'minishell_test/suites') diff --git a/minishell_test/suites/builtin.py b/minishell_test/suites/builtin.py index 2591bc3..900bd93 100644 --- a/minishell_test/suites/builtin.py +++ b/minishell_test/suites/builtin.py @@ -13,7 +13,7 @@ import os -from minishell_test import config +from minishell_test.config import Config from minishell_test import hooks from minishell_test.suite.decorator import suite from minishell_test.hooks import linux_discard @@ -26,12 +26,12 @@ def suite_echo(test): test("echo bonjour") test("echo lalalala lalalalal alalalalal alalalala") test("echo lalalala lalalalal alalalalal alalalala") - test("echo " + config.LOREM) + test("echo " + Config.lorem) test("echo -n") test("echo -n bonjour") test("echo -n lalalala lalalalal alalalalal alalalala") test("echo -n lalalala lalalalal alalalalal alalalala") - test("echo -n " + config.LOREM) + test("echo -n " + Config.lorem) test("echo bonjour -n") test("echo -n bonjour -n") test(" echo bonjour je") @@ -393,7 +393,7 @@ def suite_exit(test): test("exit bonjour 0", hook_status=hooks.platform_status(255, 2)) test("exit 0 1") test("exit 0 1 2 3 4 5 6 7 8 9") - test("exit " + config.LOREM, hook_status=hooks.platform_status(255, 2)) + test("exit " + Config.lorem, hook_status=hooks.platform_status(255, 2)) test("exit bonjoru; echo should have exited", hook_status=hooks.platform_status(255, 2)) test("exit 99999999999999999999999999999999999999999999999999999; echo should have exited", hook_status=hooks.platform_status(255, 2)) test("exit 9999; echo should have exited") diff --git a/minishell_test/suites/cmd.py b/minishell_test/suites/cmd.py index 8d2bc09..66acf97 100644 --- a/minishell_test/suites/cmd.py +++ b/minishell_test/suites/cmd.py @@ -13,7 +13,7 @@ import distutils from minishell_test import hooks -from minishell_test import config +from minishell_test.config import Config from minishell_test.suite.decorator import suite @@ -105,8 +105,8 @@ def suite_cmd(test): "asd f asd f asdf asdf asdf asd f asd f asd f asd f as df as df a" "asd f asd f asdf asdf asdf asd f asd f asd f asd f as df as df a" "asd f asd f asdf asdf asdf asd f asd f asd f asd f as df as df a") - test("echo " + config.LOREM * 10) - test("echo " + config.LOREM * 20) + test("echo " + Config.lorem * 10) + test("echo " + Config.lorem * 20) @suite() diff --git a/minishell_test/suites/flow.py b/minishell_test/suites/flow.py index aa6d395..ff3b51f 100644 --- a/minishell_test/suites/flow.py +++ b/minishell_test/suites/flow.py @@ -10,7 +10,7 @@ # # # ############################################################################ # -from minishell_test import config +from minishell_test.config import Config from minishell_test.suite.decorator import suite from minishell_test.hooks import ( error_line0, @@ -241,10 +241,10 @@ def suite_syntax_error(test): test("> a ; a", hook=error_line0) test("< a ; a", hook=error_line0) test(">> a ; a", hook=error_line0) - test(config.LOREM + " > >" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) - test(config.LOREM + " < <" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) - test(config.LOREM + " ; |" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) - test(config.LOREM + " | ;" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) + test(Config.lorem + " > >" + Config.lorem, hook=error_line0, hook_status=platform_status(2, 1)) + test(Config.lorem + " < <" + Config.lorem, hook=error_line0, hook_status=platform_status(2, 1)) + test(Config.lorem + " ; |" + Config.lorem, hook=error_line0, hook_status=platform_status(2, 1)) + test(Config.lorem + " | ;" + Config.lorem, hook=error_line0, hook_status=platform_status(2, 1)) @suite(bonus=True) @@ -289,8 +289,8 @@ def suite_syntax_error_bonus(test): test("() a", hook=error_line0, hook_status=platform_status(2, 1)) test("( a", hook=[error_line0, error_eof_to_expected_token], hook_status=platform_status(2, 1)) test(") a", hook=error_line0, hook_status=platform_status(2, 1)) - test(config.LOREM + " && &&" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) - test(config.LOREM + " || ||" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) - test(config.LOREM + " ( (" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) - test(config.LOREM + " ) )" + config.LOREM, hook=error_line0, hook_status=platform_status(2, 1)) + test(Config.lorem + " && &&" + Config.lorem, hook=error_line0, hook_status=platform_status(2, 1)) + test(Config.lorem + " || ||" + Config.lorem, hook=error_line0, hook_status=platform_status(2, 1)) + test(Config.lorem + " ( (" + Config.lorem, hook=error_line0, hook_status=platform_status(2, 1)) + test(Config.lorem + " ) )" + Config.lorem, hook=error_line0, hook_status=platform_status(2, 1)) test("(); () ;() ;() ;() ;() ;() ;() ;() ;() ;a", hook=error_line0, hook_status=platform_status(2, 1)) diff --git a/minishell_test/suites/preprocess.py b/minishell_test/suites/preprocess.py index c296dcb..e3b5ff5 100644 --- a/minishell_test/suites/preprocess.py +++ b/minishell_test/suites/preprocess.py @@ -10,7 +10,7 @@ # # # **************************************************************************** # -from minishell_test import config +from minishell_test.config import Config from minishell_test import hooks from minishell_test.suite.decorator import suite @@ -128,9 +128,9 @@ def suite_interpolation(test): test('echo $A\\ ', exports={"A": "bonjour je suis splited"}) test('echo $A\\ ', exports={"A": " bonjour je suis splited "}) test('echo $A$A$A', exports={"A": " bonjour je suis splited "}) - test("echo $A", exports={"A": "'" + config.LOREM + "'"}) - test('echo "$A"', exports={"A": "'" + config.LOREM + "'"}) - test("echo '$A'", exports={"A": "'" + config.LOREM + "'"}) + test("echo $A", exports={"A": "'" + Config.lorem + "'"}) + test('echo "$A"', exports={"A": "'" + Config.lorem + "'"}) + test("echo '$A'", exports={"A": "'" + Config.lorem + "'"}) test("$ECHO $ECHO", exports={"ECHO": "echo"}) test("$A$B bonjour", exports={"A": "ec", "B": "ho"}) test("$LS", exports={"LS": "ls -l"}, setup="touch a b c") -- cgit