Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Project
- |-api
- | \_____ __init__.py
- | \_____ mailListener.py
- |-tests
- \_____ __init__.py
- \_____ test.py
- ########################
- In mailListener I have:
- ########################
- class MailListener:
- def __init__(self):
- pass
- @staticmethod
- def get_messages_and_service():
- do smth
- return smth
- def get_mail_text(self):
- do smth2
- return smth2
- def get_url_from_mail(self):
- do smth3
- return smth3
- def mark_message_as_read(self):
- do smth4
- return smth4
- ########################
- In test.py I have:
- ########################
- import sys
- import os
- sys.path.append(os.path.join(os.path.dirname(__file__), '..')) # ANY BETTER WAY TO AVOID THIS?
- import api_.mail_listener as ml # TO IMPORT THIS???? ;)
- os.chdir(r'../api_')
- a = ml.MailListener()
- k = a.get_mail_text()
- f = a.get_url_from_mail()
- print(k)
- print(f)
- g = a.mark_message_as_read()
- And the question is: Is there any more ellegant way to import things from api_ package?
- I tried many imports, but only this one seems to work.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement