I am unable to import the main file inside my tests. Here is what my directory structure looks like:
.
├── LICENSE
├── README.md
├── invoker.py
├── main.py
├── requirements.txt
├── script.py
├── template_generators
│ ├── __init__.py
│ ├── base.py
│ ├── flipper.py
│ └── psp22.py
├── templates
│ ├── flipper
│ │ ├── cargo.txt
│ │ └── flipper.txt
│ └── psp22
│ ├── cargo.txt
│ └── psp22.txt
└── tests
├── template_generators
│ ├── test_flipper.py
│ └── test_psp22.py
└── test_cli.py
I want to import main inside test_cli.py
Here is how main.py looks like
import typer
from invoker import Invoker
def main() -> None:
print("Welcome to Ink Wizard!")
print("Type 1 to scaffold flipper contract")
print("Type 2 to scaffold psp22 contract")
contract_type = typer.prompt("Enter your choice to continue")
if contract_type == "1":
Invoker.flipper()
print("flipper scaffolded")
if contract_type == "2":
contract_name = typer.prompt("Please enter name of contract")
Invoker.psp22(contract_name=contract_name, mintable=mintable, metadata=metadata, burnable=burnable, wrapper=wrapper, flashmint=flashmint, pausable=pausable, capped=capped)
print("psp22 contract scaffolded")
if __name__ == "__main__":
typer.run(main)
Here is my test_cli.py
import typer
from typer.testing import CliRunner
import main
app = typer.Typer()
app.command()(main)
runner = CliRunner()
def test_cli() -> None:
result = runner.invoke(app, [])
assert result.exit_code == 0
When I run python test_cli.py
, here is the error I am getting:
ModuleNotFoundError: No module named 'main'
If anyone can give me an example on how to import main inside test_cli. That would be great. Thanks