title: Fastapi - run a function with dependencies outside of request
body: <p>I have two functions that my code <code>Depends</code> on, also the second one depends on the first.</p>
  <pre><code>def get_db() -&gt; Iterable[sessionmaker]:
      db = SessionLocal()
      try:
          yield db
      finally:
          db.close()
  
  def get_someservice(db: Session = Depends(get_db)) -&gt; SomeService:
      return SomeService(db)
  </code></pre>
  <p>Now in my tests I'd like to test <code>SomeService</code> but without making any requests to the app. I also want fastapi to provide the dependency.</p>
  <p>I can't just do <code>get_someservice()</code>. Is there a <code>call_function_and_provide_dependencies(get_someservice)</code> of some sort?</p>