0

Current I have two files in the same folder, in the source file I import the dlt module

# File: pipeline.py 

import dlt

Another is a test file which import nothing from the source file yet:

import sys
from unittest import mock
sys.modules['dlt'] = mock.MagicMock()


import pytest
from pyspark.sql import SparkSession


@pytest.fixture
def spark_fixture():
 spark = SparkSession.builder.appName("Testing PySpark Example").getOrCreate()
 yield spark


def test_sample():
 return True

When I run the test file, I got the error message:

    import dlt
E   ModuleNotFoundError: No module named 'dlt'
collected 0 items / 1 error

I don’t get it, here is my 2 problems:

  • I import nothing from the source file, why does python import it for me automatically? I assume this because the error is related to the ‘dlt’ module
  • Let’s take a step back. Even though I have not installed the module yet, I mock it at the entry of the testing file, why is it not working?
1

0

Browse other questions tagged or ask your own question.