diff --git a/apps/cli/executables/null/setup.py b/apps/cli/executables/null/setup.py index c6f9eb0579230ac5c5de630807344de91753ced1..91b6b575c50c3c08f10dbc16446d91301d71d40c 100644 --- a/apps/cli/executables/null/setup.py +++ b/apps/cli/executables/null/setup.py @@ -10,9 +10,9 @@ README = Path('README.md').read_text() # requires = [ # ] -# tests_require = [ -# 'pytest>=5.4,<6.0' -# ] +tests_require = [ + 'pytest>=5.4,<6.0' +] setup( name=Path().absolute().name, version=VERSION, @@ -23,7 +23,7 @@ setup( url='TBD', license="GPL", # install_requires=requires, - # tests_require=tests_require, + tests_require=tests_require, keywords=[], packages=['null'], package_dir={'':'src'}, diff --git a/apps/cli/executables/null/test/__init__.py b/apps/cli/executables/null/test/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/apps/cli/executables/null/test/null_test.py b/apps/cli/executables/null/test/null_test.py new file mode 100644 index 0000000000000000000000000000000000000000..00c756560db44f1c5aa2c947d571009312c284c4 --- /dev/null +++ b/apps/cli/executables/null/test/null_test.py @@ -0,0 +1,38 @@ +import pytest +import argparse +import sys + +from ..src.null.null import Null + +parser = argparse.ArgumentParser() + +def test_print_error(caplog): + null = Null(argparse.Namespace(), True) + null.print_error() + assert 'ERROR: This is an error.' in caplog.text + +def test_print_greeting(caplog): + null = Null(argparse.Namespace(), True) + 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) + 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) + 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) + null.take_nap() + assert 'Going to sleep...' in caplog.text + assert 'Waking up.' in caplog.text \ No newline at end of file