diff --git a/nbresult/__init__.py b/nbresult/__init__.py index 5e73df8..9272de9 100644 --- a/nbresult/__init__.py +++ b/nbresult/__init__.py @@ -67,7 +67,15 @@ def check(self): tests_directory = 'tests' if self.subdir: tests_directory = f'{tests_directory}/{self.subdir}' - result = f""" + + nbresult_post_check_message = os.getenv('NBRESULT_POST_CHECK_MESSAGE') + if nbresult_post_check_message == 'JUPYTERLAB': + result = f""" +{result}\n +:100: You can now save your changes and move on to the next challenge. +""" + else: + result = f""" {result}\n 💯 You can commit your code:\n \033[1;32mgit\033[39m add {tests_directory}/{self.name}.pickle\n diff --git a/setup.py b/setup.py index 07a9210..5a68c32 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ long_description = fh.read() setup(name='nbresult', - version='0.1.0', + version='0.1.1', description='Extract results from Jupyter notebooks', license="MIT", long_description=long_description, diff --git a/tests/test_challenge_result.py b/tests/test_challenge_result.py index e74441f..11600b2 100644 --- a/tests/test_challenge_result.py +++ b/tests/test_challenge_result.py @@ -109,3 +109,34 @@ def test_subdir_is_in_the_file_path_to_add(self): result.write() output = result.check() self.assertIn(f'add tests/{subdir}/unicity.pickle', output) + + def test_post_check_message_when_env_not_set(self): + cwd = os.getcwd() + challenge_dir = os.path.join(os.path.dirname(__file__), 'fixtures', 'package_challenge', 'toto') + subdir = 'first_tests' + tests_dir = os.path.join(challenge_dir, 'tests', subdir) + os.chdir(challenge_dir) + result = ChallengeResult('unicity', subdir=subdir, dummy=42) + result.write() + output = result.check() + # Manual tear down + os.chdir(cwd) + os.remove(os.path.join(tests_dir, 'unicity.pickle')) + + self.assertIn(f'You can commit your code', output) + + def test_post_check_message_when_env_set_to_jupyterlab(self): + cwd = os.getcwd() + challenge_dir = os.path.join(os.path.dirname(__file__), 'fixtures', 'package_challenge', 'toto') + subdir = 'first_tests' + tests_dir = os.path.join(challenge_dir, 'tests', subdir) + os.chdir(challenge_dir) + result = ChallengeResult('unicity', subdir=subdir, dummy=42) + result.write() + os.environ['NBRESULT_POST_CHECK_MESSAGE'] = 'JUPYTERLAB' + output = result.check() + # Manual tear down + os.chdir(cwd) + os.remove(os.path.join(tests_dir, 'unicity.pickle')) + os.environ['NBRESULT_POST_CHECK_MESSAGE'] = '' + self.assertIn(f'You can now save your changes and move on to the next challenge', output)