mercredi 2 septembre 2020

How to execute pytest from code on test functions in module

I'm working in a managed notebook environment (Databricks). All I have access to is the notebook itself, where I want to execute integration tests.

Is it possible to get pytest to pick up the test_ functions in the current scope instead of scanning through files?

I'm looking for something like this:

import pytest


@pytest.fixture(scope='session')
def session_fixture():
  return ""

def test_this_1(session_fixture):
  assert False
  
def test_this_2(session_fixture):
  assert True
  
pytest.<<pytest command to pytest `test_this_1` and `test_this_2`>>

Aucun commentaire:

Enregistrer un commentaire