This repository was archived by the owner on Sep 10, 2025. It is now read-only.
Commit 844b4cb
committed
Fix the way tests run
Currently `torchtext` runs tests by `pytest test`. This is fine for development but one cannot run unit test on installed package in this manner because running test from the root adds the current directory as module search path and this will shadow the installed package. Similarly if you do `(cd test && pytest .)`, this does not work either because `pytest` will 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=False` issue. (this cannot be caught with the current configuration)
To resolve this issue, this PR
1. introduces `test/torchtext_unittest` directory and moves all the test scripts and assets there.
2. changes `python setup.py develop` to `python setup.py install` in CI job
3. run test with `(cd test && pytest torchtext_unittest)` so that repository root is not in Python module search path.
4. Change relative import (`from ..common import ...`) in test module to absolute import (`from torchtext_unittest.common import ...`)
5. deletes `pytest.ini`, which hard-coded test path.1 parent 34ccda8 commit 844b4cb
File tree
57 files changed
+41
-34
lines changed- .circleci/unittest
- linux/scripts
- windows/scripts
- test/torchtext_unittest
- asset
- common
- data
- experimental
- legacy
- data
- models
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
57 files changed
+41
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
0 commit comments