Skip to content

Commit

Permalink
[Test] Enhance test experience (#1281)
Browse files Browse the repository at this point in the history
  • Loading branch information
sotetsuk authored Nov 3, 2024
1 parent f88f304 commit b1dc605
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ dds_results
wandb
checkpoints
__pycache__
tests/assets/*/*.svg
9 changes: 7 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
"editor.insertSpaces": true,
},
"python.testing.pytestArgs": [
"mypkg",
"--doctest-modules"
"-n 4",
"-vv",
"tests",
"--doctest-modules",
"pgx",
"--ignore",
"pgx/experimental",
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ uninstall:
python3 -m pip uninstall pgx -y

test:
python3 -m pytest --doctest-modules --verbose pgx tests/test_*.py --ignore=pgx/experimental
python3 -m pytest -n 4 -vv tests --doctest-modules pgx --ignore pgx/experimental

test-with-codecov:
python3 -m pytest --doctest-modules --verbose pgx tests/test_*.py --ignore=pgx/experimental --cov=pgx --cov-report=term-missing --cov-report=html
python3 -m pytest -n 4 -vv tests --doctest-modules pgx --ignore pgx/experimental --cov=pgx --cov-report=term-missing --cov-report=html
10 changes: 8 additions & 2 deletions pgx/_src/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ def api_test_single(env: Env, num: int = 100, use_key=True):
# check visualization
filename = "/tmp/tmp.svg"
state.save_svg(filename)
os.remove(filename)
try:
os.remove(filename)
except FileNotFoundError:
pass


def api_test_batch(env: Env, num: int = 100, use_key=True):
Expand Down Expand Up @@ -112,7 +115,10 @@ def api_test_batch(env: Env, num: int = 100, use_key=True):
# check visualization
filename = "/tmp/tmp.svg"
state.save_svg(filename)
os.remove(filename)
try:
os.remove(filename)
except FileNotFoundError:
pass


def _validate_init_reward(state: State):
Expand Down
1 change: 1 addition & 0 deletions requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
jaxlib
pytest
pytest-xdist
matplotlib
ipython
# hot fix. to avoid errors in Py3.8
Expand Down

0 comments on commit b1dc605

Please sign in to comment.