0

Why the next code works

python test.py
#Import libraries modules

import pandas as pd
import numpy as np
from clases.read_file import ReadFile
user_input='/home/folder1/Application/clases/file.txt'

#Test1
#Test data loaded from VCF file
data=Read File(user_input)
data_loaded data.load_data()

print(data_loaded.shape)

# Output (64, 10)

However, the next one doesn't work

pytest test.py
#Import libraries modules

import pandas as pd
import numpy as np
from clases.read_file import ReadFile

user_input='/home/folder1/Application/clases/file.txt'

#Test1
#Test data loaded from VCF file
data=Read File(user_input)
data_loaded data.load_data()

def test_1 ():
    assert data_loaded.shape == '(64, 10)'

Output:

E   ModuleNotFoundError: No module named 'clases'

It is the same file before and after changing the lines that differ. So they are in the same directory.

Why clases is recognized when called by python but it is not when using pytest

Directory structure

run.py
__init__.py
test.py
clases
     |- read_file.py
     |- __init__.py
     |
other_files

I am running this in an HPC Linux based

0 Answers0