def test_logs(): bs = BuildSpace(root_dir=os.getcwd(), primitive='build') bs.create() bs.set_logging() bs.end() assert os.path.isfile(bs.log_file) with open(bs.log_file) as f: assert 'anod primitive: build' in f.read()
def test_live_logs(): bs = BuildSpace(root_dir=os.getcwd(), primitive='build') bs.create() bs.set_logging(stdout_logs=True) bs.log_stream.write('here') bs.log_stream.flush() bs.log_stream.write('there') time.sleep(0.2) # let enough time to cover the tail_thread code bs.end() with open(bs.log_file) as f: assert 'here' in f.read()