I have been trying to run unit tests using pytest in Python. I had written a module with one class and some methods inside that class. I wrote a unit test for this module (with a simple assert statement to check equality of lists) where I first instantiate the class with a list. Then I invoke a method on that object (from the class). Both test.py
and the script to be tested are in the same folder. When I run pytest
on it, I get "collected 0 items".
I am new to pytest
, and but I am unable to run their examples successfully. What am I missing here?
I am running Python version 3.5.1 and pytest version 2.8.1 on Windows 7.
My test.py code:
from sort_algos import Sorts
def integer_sort_test():
myobject1 = Sorts([-100, 10, -10])
assert myobject1.merge_sort() == [-101, -100, 10]
sort_algos.py is a module containing class Sorts
. merge_sort is a method under Sorts
.
.py
file? – Zulan.py
being skipped if it's executable - see if it is and either change it to non-executable, or see ifpytest
has ainclude executable
option? – dwanderson