09/30/2020, 11:08 AM
Hi everyone! Does anyone have an example project structure that includes tests? I’m struggling to get my imports etc working

Timothy Byrne

09/30/2020, 2:27 PM
Not sure if this helps, but Cookiecutter may be an option
👍 1

Alexander Pospiech

10/01/2020, 6:52 AM
Yes. I'm also experiencing strange behaviour when I use pytest to test prefect tasks. Called with pytest the python test file works. Called with python there are strange module import errors. Is that also your case @Adam?

Simone Cittadini

10/01/2020, 9:44 AM
I have code under 'src', tests under 'tests' at the same level of 'src', calling pytest from that level (PROJECT_ROOT) with PYTHONPATH="$PROJECT_ROOT/src:$PYTHONPATH" pytest $TESTS_DIR tests are like :
def test_zipfiles(mocker: MockerFixture) -> None:
# sometimes I mock stuff, usually context stuff
with Flow(name="test") as flow:  # type: ignore
task = TaskUnderTest(... confs)
output = task(... args)
res =
assert res.result[output].result == ... expected result


10/01/2020, 1:22 PM
@Alexander Pospiech I did indeed have that problem initially. Running the tests like this:
python -m pytest tests/
helped iirc. My problem now is that the above command results in a lot of the test files failing. However if I run them individually they work. The errors I get are
TypeError: 'builtin_function_or_method' object is not iterable