Reputation: 29655
I am new to py.test and want to simply write some test functions next to some other functions in a Python file.
My main file is called something like myfile.py
. Inside that file I have a function. For example:
def pad(bytes):
return " "*bytes
I want to verify the behavior of the function:
def test_pad():
assert pad(3)==" "
The problem is my test_pad()
function never runs. It does run if I put it in a file called test_myfile.py
and that file does an import
, but that seems like a lot of overhead.
Whats the proper way to do this?
Upvotes: 0
Views: 128
Reputation: 29655
Create a file called pytest.ini
:
[pytest]
python_files=*.py
See Changing standard (Python) test discovery for more details. (It's not that obvious.)
Upvotes: 1