Pytest stuck on 'collecting...'

I have a file new_script_piped.py with a function I want to test:

def columns_preparation(df):

    df.COLUMN_1.replace({'-999':'don't consider'}, inplace=True)
    ...more lines

    return df

and the test file test_new_script_piped.py

import pandas as pd
import new_script_piped as x

def test_columns_preparation(df):

    test_df = pd.read_excel('test_column_preparation.xlsx')
    result_df = pd.read_excel('test_column_preparation_result.xlsx')

    assert x.columns_preparation(test_df) == result_df

All files are in the same directory. I have tried on the command line:

python3 -m pytest new_script_piped.py
pytest new_script_piped.py
python -m pytest new_script_piped.py

and they all get suck at:

platform darwin -- Python 3.7.3, pytest-4.5.0, py-1.8.0, pluggy-0.11.0
rootdir: /Users/31275553/Documents/
collecting ... 

Other solutions advise to check on spelling mistakes and to make sure all files are in the same folder, but I already comply that. My python interpreter is: /.conda/envs/untitled/bin/python


Your test is probably taking a long time

pytest -s path_to_script.py  

In order to see stdout if you have any progress prints


I was able to reduce the "Collecting..." delay by a significant margin by narrowing down which directories are searched for tests, which achieves the same effect as finomayato's answer, through config rather than supplying the path to the tests as an argument.

Based on example from the docs, let's say you want to make sure pytest isn't digging down into your git, build, or frontend dependency directories looking for tests:

# content of pytest.ini
[pytest]
norecursedirs = .git build node_modules

https://docs.pytest.org/en/latest/example/pythoncollection.html#changing-directory-recursion