-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Error Handling]: ImportError while importing test module (Error-Handling Messaging & Exercises) #2275
Comments
Please also show us the content of your \cc @exercism/python |
Hi, Norbert. Thank you for the reply. Here is my code.
I see the line you're referring to for the import error. Normally, I fill in the function definitions as provided in the .py file for the exercise. Am I supposed to create a MeetupDayException? Thank you, |
Hi @dan9731 👋 Since @NobbZ is in CET, I'm picking this up. (I'm in PST). Apologies - the test file for this exercise appears to have been updated since you last worked on/ran it, and it is indeed expecting you to define a To get around this (temporarily) you can add the following to the top of your from meetup import meetup
try:
from meetup import MeetupDayException
except ImportError:
MeetupDayException = Exception That way, you can run and work on any tests that might be failing right now for you. When I ran your code, it looks as though 7 of the 90 tests have failed -- mostly for To fully pass all the tests without the test file modification, you will need to make a custom class MeetupDayException(Exception):
"""Exception raised when the meetup day is not valid or in range..
Attributes:
day -- the day that is causing the error
message -- explanation of the error
"""
def __init__(self, day, message="Isn't valid as a proposed meetup date. Please try another."):
self.day = day
self.message = message
super().__init__(self.message)
def meetup(year, month, week, day_of_week):
try:
meetup = meetup_check(year, month, week, day_of_week)
except Exception as err:
raise MeetupDayException(f'{day_of_week}, week {week}, in {month}, of {year}') As you can see, I've made a function that is named For more detail on how to create/customize and handle errors, take a look at the docs here. Please let us know if this works for you, and if you have any additional questions or issues. Best, |
OK... I think I get it. I was able to mend my code to get pytest working with both the modifications to the pytest file you suggested and also after adding the MeetupDayException class. And I was able to weed out those ValueErrors too. =) This was very helpful. Thank you so much, @BethanyG ! |
@iHiD this issue may be moved to exercism/python |
@BethanyG I would like to leave this open as a reference issue until we've made the changes we talked about. |
This issue has been automatically marked as |
Going to comment here since we still have changes that require this to be open. Removing the [abandoned] tag. |
Good day. I first offer the obligatory "I'm not GitHub-savvy" apology. I did look for an answer as prescribed here, following steps in subheading Opening an Issue. But I have not seen anything. I've seen some fixes on Stack Overflow. But they make no sense to me. Please don't crush me if I'm doing this wrong.
I'm working on a new linux install. On my previous installation, I ran pytest successfully many times (28 to be precise). With this new installation, I've run it once successfully on exercise Twelve Days of Christmas. It's giving me this error now:
I tried removing the meetup directory and re-downloading from the CLI. I get this error no matter what the contents of meetup.py are. So, I'm guessing that I have some issue either with they way pytest is configured or with my meetup_pytest file.
Any assistance greatly appreciated.
Thank you so much.
Dan.
The text was updated successfully, but these errors were encountered: