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

__init__.py added for testing individual files in tests/openai #318

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

zby
Copy link
Contributor

@zby zby commented Jan 2, 2024

This is needed for running pytest tests/openai/test_modes.py.
Without it I get:

zby@zby-Z4:~/gpt/instructor$ pytest tests/openai/test_modes.py 
====================================================================================================== test session starts ======================================================================================================
platform linux -- Python 3.10.12, pytest-7.4.3, pluggy-1.2.0
rootdir: /home/zby/gpt/instructor
plugins: anyio-3.6.1, asyncio-0.21.1
asyncio: mode=strict
collected 0 items / 1 error                                                                                                                                                                                                     

============================================================================================================ ERRORS =============================================================================================================
__________________________________________________________________________________________ ERROR collecting tests/openai/test_modes.py __________________________________________________________________________________________
ImportError while importing test module '/home/zby/gpt/instructor/tests/openai/test_modes.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/openai/test_modes.py:8: in <module>
    from tests.openai.util import models, modes
E   ModuleNotFoundError: No module named 'tests.openai'
==================================================================================================== short test summary info ====================================================================================================
ERROR tests/openai/test_modes.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================================================================= 1 error in 0.07s ========================================================================================================
zby@zby-Z4:~/gpt/instructor$ 

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Summary:

This PR adds an init.py file in the tests/openai directory to resolve a ModuleNotFoundError when running individual test files with pytest.

Key points:

  • Added init.py in tests/openai directory to allow individual test files to be run using pytest.

Generated with ❤️ by ellipsis.dev

@jxnl jxnl merged commit 3f1c991 into jxnl:main Jan 2, 2024
7 checks passed
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

Successfully merging this pull request may close these issues.

2 participants