From 671b42bdabe055d2d717e2dd7d1c68059afea9ab Mon Sep 17 00:00:00 2001 From: "jai.s" Date: Thu, 15 Oct 2020 21:15:09 +0530 Subject: [PATCH] Added traceback for identify the testcases name and removed print functions --- src/bitmessagemain.py | 3 --- src/tests/test_process.py | 28 +++++++++------------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index cfac0967..93274490 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -23,7 +23,6 @@ import traceback from struct import pack try: - print('222222222222222trybitmessagemain testing for the bitmessgemain') import defaults import depends import shared @@ -50,7 +49,6 @@ try: from helper_test import TestCoreDummy except ModuleNotFoundError: - print('333333333333block except bitmessagemain testing for the bitmessgemain') from pybitmessage import defaults from pybitmessage import depends from pybitmessage import shared @@ -77,7 +75,6 @@ except ModuleNotFoundError: addressGenerator, objectProcessor, singleCleaner, singleWorker, sqlThread) from pybitmessage.helper_test import TestCoreDummy - print('44444444444444444444444444444444444') app_dir = os.path.dirname(os.path.abspath(__file__)) os.chdir(app_dir) diff --git a/src/tests/test_process.py b/src/tests/test_process.py index f41e821a..bd250aee 100755 --- a/src/tests/test_process.py +++ b/src/tests/test_process.py @@ -8,7 +8,7 @@ import subprocess # nosec import tempfile import time import unittest - +import traceback try: import psutil except ModuleNotFoundError: @@ -44,8 +44,9 @@ class TestProcessProto(unittest.TestCase): time.sleep(5) cls.pid = int(cls._get_readline('singleton.lock')) cls.process = psutil.Process(cls.pid) - print('') - + print('traceback in setupClass') + print(traceback.format_stack()) + @classmethod def _get_readline(cls, pfile): pfile = os.path.join(cls.home, pfile) @@ -59,17 +60,13 @@ class TestProcessProto(unittest.TestCase): def _stop_process(cls, timeout=120): cls.process.send_signal(signal.SIGTERM) try: - print('1111111111111111111111111111111111111111') print('In the _stop_process_ method ,after the term signal wait process are started') - print('1111111111111111111111111111111111111111') cls.process.wait(timeout) - print('222222222222222222222222222222222222') print('In the _stop_process_ method ,wait process are completed') - print('222222222222222222222222222222222222') except psutil.TimeoutExpired: - print('33333333333333333333333333333333') + print('traceback in _stop_process') + print(traceback.format_stack()) print('In the _stop_process_ method ,psutil.timoutExpired is occured') - print('33333333333333333333333333333333') return False return True @@ -87,27 +84,20 @@ class TestProcessProto(unittest.TestCase): """Ensures that pybitmessage stopped and removes files""" try: if not cls._stop_process(): - print('444444444444444444444444444444') print('In the tearDownClass ,initiating the process Killing') - print('44444444444444444444444444444') cls.process.kill() - print('5555555555555555555555555555555') print('In the tearDownClass ,initiating the process wait') - print('55555555555555555555555555555') cls.process.wait(5) - print('6666666666666666666666666666') print('In the tearDownClass ,Process killied ?') - print('666666666666666666666666666666') except (psutil.NoSuchProcess, FileNotFoundError, AttributeError) as e: - print('77777777777777777777777777') print('In the tearDownClass ,psutil.NoSuchProcess,FileNotFoundError, AttributeError') + print('traceback in tearDownClass') + traceback.format_stack() print(str(e)) - print('77777777777777777777777777') except psutil.TimeoutExpired as e: - print('88888888888888888888888') print('In the tearDownClass ,psutil.TimeoutExpired is occurred') + traceback.format_stack() print(str(e)) - print('888888888888888888888888') finally: cls._cleanup_files()