https://learn.microsoft.com/en-us/azure ... ks/testing
ImportError while importing test module '/Workspace/python_tests/dummy_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.12/importlib/__init__.py:90: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
E ModuleNotFoundError: No module named 'dummy_test'
=========================== short test summary info ============================
ERROR dummy_test.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.45s ===============================
Это структура моего каталога /Workspace/python_tests и каждого файла:
- dummy.py
from pyspark.sql import SparkSession
from pyspark.sql.functions import col
# Because this file is not a Databricks notebook, you
# must create a Spark session. Databricks notebooks
# create a Spark session for you by default.
spark = SparkSession.builder.appName('integrity-tests').getOrCreate()
def dummy():
return "I am a dummy"
- dummy_test.py
import pyspark
from dummy import *
def test_dummy():
assert dummy() == "I am a dummy"
- pyTestRunner (блокнот)
import pytest
import sys
# Skip writing pyc files on a readonly filesystem.
sys.dont_write_bytecode = True
# Run pytest.
retcode = pytest.main([".", "-v", "-p", "no:cacheprovider"])
# Fail the cell execution if there are any test failures.
assert retcode == 0, "The pytest invocation failed. See the log for details."
Подробнее здесь: https://stackoverflow.com/questions/793 ... s-notebook