diff --git a/apps/cli/executables/null/test/null_test.py b/apps/cli/executables/null/test/test_null.py similarity index 65% rename from apps/cli/executables/null/test/null_test.py rename to apps/cli/executables/null/test/test_null.py index c8da965d01f90115d887e9e61fc7dd6bb12114b5..7dd49717c246daa13db90f959016aa4ce59af8dc 100644 --- a/apps/cli/executables/null/test/null_test.py +++ b/apps/cli/executables/null/test/test_null.py @@ -1,37 +1,36 @@ import pytest import argparse -from null.null import Null +# from null.null import Null +from ..src.null.null import Null -parser = argparse.ArgumentParser() - -def test_print_error(caplog): +@pytest.fixture() +def null(): null = Null(argparse.Namespace(), True) + return null + +def test_print_error(null, caplog): null.print_error() assert 'ERROR: This is an error.' in caplog.text -def test_print_greeting(caplog): - null = Null(argparse.Namespace(), True) +def test_print_greeting(null, caplog): null.print_greeting() assert 'Hello, world!' in caplog.text assert 'And goodbye, world...' in caplog.text -def test_exit_with_failure(caplog): - null = Null(argparse.Namespace(), True) +def test_exit_with_failure(null, caplog): with pytest.raises(SystemExit) as e: null.exit_with_failure() assert 'Error purposefully induced. Exiting with status code -1...' in caplog.text assert e.value.code == -1 -def test_exit_randomly(caplog): - null = Null(argparse.Namespace(), True) +def test_exit_randomly(null, caplog): with pytest.raises(SystemExit) as e: null.exit_randomly() assert 'Exiting with status code' in caplog.text assert -50 <= e.value.code <= 50 -def test_take_nap(caplog): - null = Null(argparse.Namespace(), True) +def test_take_nap(null, caplog): null.take_nap() assert 'Going to sleep...' in caplog.text assert 'Waking up.' in caplog.text \ No newline at end of file