Skip to content
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

[Lasagna]: ImportError While Doing Exercise #3181

Closed
LindaK92 opened this issue Oct 14, 2022 · 7 comments · Fixed by #3339
Closed

[Lasagna]: ImportError While Doing Exercise #3181

LindaK92 opened this issue Oct 14, 2022 · 7 comments · Fixed by #3339
Assignees
Labels

Comments

@LindaK92
Copy link

Hi all!

I hope this forum is the right place to put bugs.

I am doing excersise 2 (Lasagna) from Python and I get an import error, see below.
I do not think I made a mistake with programming, because I have also looked at the solutions from the community and when I enter the exact same solution, it gives the same error. Now I cannot continue.

So how can this problem be fixed? Thank you very much!

"
We received the following error when we ran your code:

ImportError while importing test module '.mnt.exercism-iteration.lasagna_test.py'.
Hint: make sure your test modules.packages have valid Python names.
Traceback:
.mnt.exercism-iteration.lasagna_test.py:6: in
from lasagna import (EXPECTED_BAKE_TIME,
E ImportError: cannot import name 'EXPECTED_BAKE_TIME' from 'lasagna' (.mnt.exercism-iteration.lasagna.py)

During handling of the above exception, another exception occurred:
.usr.local.lib.python3.10.importlib.init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
.mnt.exercism-iteration.lasagna_test.py:23: in
raise ImportError("In your 'lasagna.py' file, we can not find or import the"
E ImportError: In your 'lasagna.py' file, we can not find or import the function named 'EXPECTED_BAKE_TIME()'. Did you mis-name or forget to define it?
"

@github-actions

This comment was marked as duplicate.

@BethanyG
Copy link
Member

BethanyG commented Oct 14, 2022

Hi @LindaK92 👋🏽

Thanks for filing this issue. As the Python track maintainer, i'd like to apologize -- that is bad logic in the test file, resulting in a bogus error message. We're using the logic for a missing function name, but it needs to be doing something different here. We'll try to get that bug fixed as quickly as we can.

However - mixed up in that erroneous message is a legitimate problem telling you that the test runner cannot import a name that it needs. It sadly happens to be lying about what kind of name it is trying to import. 🤦🏽‍♀️

The tests are looking for a constant named EXPECTED_BAKE_TIME, defined (usually) at the top of the file like so:

EXPECTED_BAKE_TIME = <replace with some numeric value you fill in here>
PREPARATION_TIME = <replace with some other numeric value you fill in here>


def bake_time_remaining(time):
    return <replace with code that uses the constants here>

def preparation_time_in_minutes(num_layers):
    return <replace with more code you fill in here>

For the quick test I did in my account on the website, if I don't have that first line defining the constant, I get the same stack trace you do. I think if you define (and use) that missing constant, the test runner will stop complaining.

Please let me know if that is not the case, and I'll try to help you further with getting unstuck (or help identify any additional bugs).

Again - apologies for the lying test runner. 😉

@iHiD or @ErikSchierboom -- could one of you transfer this to the python repo? Many thanks!

@iHiD iHiD transferred this issue from exercism/exercism Oct 15, 2022
@github-actions

This comment was marked as duplicate.

@bo1658a
Copy link

bo1658a commented Feb 23, 2023

I did the Hello_world test and encountered an error on submission as seen below. Kindly assist.

We received the following error when we ran your code:
ImportError while importing test module '.mnt.exercism-iteration.hello_world_test.py'.
Hint: make sure your test modules.packages have valid Python names.
Traceback:
.usr.local.lib.python3.10.importlib.init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
.mnt.exercism-iteration.hello_world_test.py:3: in
from hello_world import (
E ImportError: cannot import name 'hello' from 'hello_world' (.mnt.exercism-iteration.hello_world.py)

@BethanyG
Copy link
Member

Hi @bo1658a 👋🏽

As stated in the auto-response for the last issue you opened on this repo, we would prefer if you first raised issues in our exercism forum, and not here in the Python repo.

The forum has many friendly people who would love to discuss and help students with issues they encounter. Another alternative is to use our CLI to upload your partial solution and request mentoring. A mentor can walk through your solution and point out where things might have gone wrong.

My reply in this forum post might also be helpful for you.

In the future, please don't comment on an unrelated exercise (this issue is in regards to Guido's Gorgeous Lasagna and not Hello World), as it creates confusion and noise.

Many thanks, and good luck with the exercise.

@BethanyG BethanyG changed the title ImportError while doing exercise [Lasagna]: ImportError While Doing Exercise Feb 23, 2023
@BethanyG
Copy link
Member

@ErikSchierboom or @iHiD - any chance I could get eyes/approvals for the following related issues?
I know it won't fix Hello World, but I do think it would help with the complaints we're getting on Lasagna.
Many thanks!

#3339, #3344, and python-test-runner #110.

@ErikSchierboom
Copy link
Member

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants