ImportError on "dnd_character.py" Exercise

Hello,

I am getting this error. I submitted a bug report but never heard anything.

I get the error even if I “Revert to exercise start” and try submitting.

Thanks!

  ImportError while importing test module '.mnt.exercism-iteration.dnd_character_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.dnd_character_test.py:3: in <module>
    from dnd_character import (
E   ImportError: cannot import name 'modifier' from 'dnd_character' (.mnt.exercism-iteration.dnd_character.py)

Could you please post your code here? I suspect something like a typo.

You can keep your post compact by using

[details="Summary"]
This text will be hidden
[/details]

which will render as

Summary

This text will be hidden

I get that error even before adding any code of my own:

class Character:
def init(self):
pass

Something to do with this?

image

Correct. In this exercise you have to implement a class Character with an initializer (__init__) and a method ability, and also a free function modifier.

More broader, if the tests throws an ImportError complaining it cannot import <name> from <container>, then that container (module, file) is expected to define something with that name.

Ah ok, my ‘modifier’ was a class method.

Thanks!!

If it expected a class method and that method was missing, you’d see:

AttributeError: 'Character' object has no attribute 'modifier'
1 Like