I'm getting the following error when try to use pytest
to run my tests:
tests/main_test.py:1: in <module>
from src.main import main
src/main.py:1: in <module>
from string_helper import string_sum
E ModuleNotFoundError: No module named 'string_helper'
My project is very simple, here is the structure:
src/main.py
from string_helper import string_sum
def main():
a = 2
b = 1
r = string_sum(a, b)
#print(r)
return r
if __name__ == "__main__":
r = main()
print(r)
src/string_helper.py
def string_sum(a, b):
return str(a + b)
tests/main_test.py
from src.main import main
def test_string_sum():
r = main(1, 2)
assert type(r) is str
assert r == "3"
Here is the repl.it if you want to run it in web browser: https://replit.com/@gmunumel/TestCasesExample?v=1. Run pytest -v
and install the latest version of the package. You should see the error.