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

How to write a module and test it #869

Open
fdsgdshn opened this issue Apr 2, 2024 · 1 comment
Open

How to write a module and test it #869

fdsgdshn opened this issue Apr 2, 2024 · 1 comment

Comments

@fdsgdshn
Copy link

fdsgdshn commented Apr 2, 2024

Hi,

I'm looking to create a module in Transcrypt and also write an auto-test module for it. What steps should I take to accomplish this? I've created a file named enum_new under transcrypt/modules/enum_new, and I've defined a class named MyEnum within it. However, when I try to test it under transcrypt/development/automated_tests/transcrypt/module_enum/ , even after importing the class, it seems to be inaccessible. Could you provide some guidance on this matter?

The error message is as follows:

from enum_new import *
ModuleNotFoundError: No module named 'enum_new'
Aborted

But python couldn't find this new module named enum_new.

Thanks!

@JennaSys
Copy link
Collaborator

It sounds like you are running into namespace issues. Are you using an __init__.py file in the modules/enum_new/ and automated_tests/transcrypt/module_enum/ folders?

In module_enum/__init__.py you should be able to import your class normally and then use it in a call to autoTester.check() to set up the test.

You will also need to import module_enum and add a call to autoTester.run (module_enum, 'module_enum') in automated_tests/transcrypt/autotest.py to have it actually run as part of the automated tests for transcrypt.

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

No branches or pull requests

2 participants