@pytest.hookimpl(hookwrapper=True)
def pytest_sessionfinish(exitstatus):
 outcome = (yield)
 outcome.get_result()
 cache_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..', '.cache')
 try:
  os.mkdir(cache_dir)
 except FileExistsError:
  pass
 status_file = os.path.join(cache_dir, 'pytest_status')
 with open(status_file, 'w', encoding='ascii') as f:
  f.write(str(exitstatus))

@ pytest . hookimpl ( hookwrapper = True ) def pytest_sessionfinish ( exitstatus ) : outcome = ( yield ) outcome . get_result ( ) cache_dir = os . path . join ( os . path . abspath ( os . path . dirname ( __file__ ) ) , '..' , '.cache' ) try : os . mkdir ( cache_dir ) except FileExistsError : pass status_file = os . path . join ( cache_dir , 'pytest_status' ) with open ( status_file , 'w' , encoding = 'ascii' ) as f : f . write ( str ( exitstatus ) )
create a file to tell run_pytest .