Skip to content

Correct way to share code between tests of different components #263

Discussion options

You must be logged in to vote

We did something similar. To prevent test code from polluting components, we created a test_utils component and put component-specific test code in submodules of test_utils. In your example, I think test code for foo and bar would be located in bar.test_utils.foo and bar.test_utils.bar respectively.

That way test code is reusable but separate from components so it doesn't slip into project artifacts (i.e. Docker images and pip packages).

Side note: components should not be a module. To import fixtures, it should be: from bar.test.bar import fixtures. To make that work, we had to add components and bases to our PYTHONPATH. Like this:

export PYTHONPATH="${PWD}/components:${PWD}/bases"

We us…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by DavidVujic
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants