Question
How can I import helper functions in test files without creating packages in the test
directory?
Contex
You could define a helper class in conftest.py, then create a fixture that returns that class (or an instance of it, depending on what you need).
import pytest
class Helpers:
@staticmethod
def help_me():
return "no"
@pytest.fixture
def helpers():
return Helpers
Then in your tests, you can use the fixture:
def test_with_help(helpers):
helpers.help_me()