0

I need to import enum class which sits in dir A from some other file which is in dir B. So I have the following:

- enums
 -- __init__.py
 -- flavors.py
- setUp
 -- test.py
flavors.py
from enum import Enum, unique


@unique
class Flavor(Enum):
    VANILLA = "vanilia"
    CHOCOLATE = "chocolate"
    MINT = "mint"

In the test.py I just need to import this enum, but whatever way I chose getting

ModuleNotFoundError: No module named 'enums'

1
  • 1
    Please show the attempts you made. Commented Dec 5, 2024 at 15:30

1 Answer 1

0

I think what you're trying to achieve is something like this: For example, you wanna use the Enum (Flavor) in a new Enum you create in test.py.

In your test.py file, You can try something like:

from enums.flavors import Flavor


class TestEnum(Flavor):
    BROWN_CHOCOLATE = "brownchocolate"
    PEPPERMINT = "peppermint"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.