This repository was archived by the owner on Sep 10, 2025. It is now read-only.
Fix the way tests are executed #1223
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently
torchtextruns tests bypytest test. This is fine for development but one cannot run unit test on installed package in this manner because running test from the root directory adds the current directory as module search path and the checked out code directory will shadow the installed package. Similarly if you do(cd test && pytest .), this does not work either becausepytestwill figure out where the test module root starts and add the repository root to python module search path.When running test on CI, it is more desirable to install the package and run tests because it can catch a bug related to packaging. Such as
zip_safe=Falseissue. (this cannot be caught with the current configuration)To resolve this issue, this PR
test/torchtext_unittestdirectory and moves all the test scripts and assets there.python setup.py developtopython setup.py installin CI job(cd test && pytest torchtext_unittest)so that repository root is not in Python module search path.from ..common import ...) in test module to absolute import (from torchtext_unittest.common import ...)pytest.ini, which hard-coded test path.