def test_pid_from_logname(self): s = 'caffe.host.user.log.INFO.20151001-132750.26943' res = lu.pid_from_logname(s) assert_is_instance(res, int) assert_equal(res, 26943) n = 77775 s = 'log.%s' % n res = lu.pid_from_logname(s) assert_is_instance(res, int) assert_equal(res, n)
def test_pid_from_logname(): s = 'caffe.host.user.log.INFO.20151001-132750.26943' res = lu.pid_from_logname(s) assert_is_instance(res, int) assert_equal(res, 26943) n = 77775 s = 'log.%s' % n res = lu.pid_from_logname(s) assert_is_instance(res, int) assert_equal(res, n)
def test_pid_from_logname_invalid(): s = 'caffe.host.user.log.INFO.20151001-132750.26943.txt' res = lu.pid_from_logname(s) assert_is_instance(res, int) assert_equal(res, -1)
def test_read_pid_from_content(self): fpath = os.path.join(os.path.dirname(ROOT_PKG_PATH), TEST_DATA_DIRNAME, TEST_LOG_FILENAME) path_temp_dir = tempfile.mkdtemp() fpath2 = os.path.join(path_temp_dir, "foo.txt") shutil.copyfile(fpath, fpath2) try: assert_less(lu.pid_from_logname(fpath2), 0) result = lu.read_pid(fpath2) assert_is_instance(result, int) assert_equal(result, 31405) except Exception: pass shutil.rmtree(path_temp_dir)