Skip to content

Commit

Permalink
tests: remove nose (#1664)
Browse files Browse the repository at this point in the history
Closes #1647
  • Loading branch information
NeoLegends authored Dec 11, 2024
1 parent d0d1801 commit 4c6e245
Show file tree
Hide file tree
Showing 27 changed files with 1,246 additions and 1,351 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ jobs:
pip install --user typing # needed for Python 2 in some cases
pip install --user pytest
pip install --user nose
pip install --user dm-tree h5py typing
pip install --user --progress-bar=off "numpy<2"
Expand Down Expand Up @@ -138,9 +137,6 @@ jobs:
pip install --user pytest
# Install nose anyway because we currently use some of its helper functions.
pip install --user nose
pip install --user --progress-bar=off -r requirements.txt
- name: Test Python/Numpy/TF versions.
Expand Down Expand Up @@ -225,9 +221,6 @@ jobs:
pip install --user pytest
# Install nose anyway because we currently use some of its helper functions.
pip install --user nose
if [[ "${{matrix.tf-version}}" == 2.[0123].* || "${{matrix.tf-version}}" == 1.* ]]; then
# Older TF needs older NumPy version.
# https://github.com/rwth-i6/returnn/pull/1160#issuecomment-1284537803
Expand Down Expand Up @@ -309,9 +302,6 @@ jobs:
pip install --user pytest
# Install nose anyway because we currently use some of its helper functions.
pip install --user nose
pip install --user dm-tree h5py typing
pip install --user --progress-bar=off "numpy<2"
pip install --user --progress-bar=off scipy # for some tests
Expand Down Expand Up @@ -400,9 +390,6 @@ jobs:
pip install --user pytest
# Install nose anyway because we currently use some of its helper functions.
pip install --user nose
pip install --user dm-tree h5py typing
pip install --user --progress-bar=off "numpy<2"
pip install --user --progress-bar=off scipy # for some tests
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced/test_suite.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ by GitHub Actions defined `here <https://github.com/rwth-i6/returnn/blob/master/

The test cases are all in the `tests directory <https://github.com/rwth-i6/returnn/tree/master/tests>`__.

We use nosetests but the tests can also be run manually like::
We use pytests but the tests can also be run manually like::

python3 tests/test_TFEngine.py

Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ and for PyTorch, use :code:`pip install torch torchaudio`.

For some specific datasets or special layers, additional dependencies might be needed,
such as ``librosa``.
For running the tests, you need ``pytest`` and ``nose``.
For running the tests, you need ``pytest``.

You can also install RETURNN as a framework, via ``pip`` (`PyPI entry <https://pypi.org/project/returnn/>`__),
like::
Expand Down
1 change: 0 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
numpy<2
scipy
h5py
nose
pytest
dm-tree
tensorflow==2.12.1
Expand Down
1 change: 0 additions & 1 deletion requirements-dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
black==22.3.0
nose
pytest
79 changes: 39 additions & 40 deletions tests/test_Config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sys
import _setup_test_env # noqa
import unittest
from nose.tools import assert_equal, assert_is_instance, assert_in, assert_greater, assert_true, assert_false
from pprint import pprint
from returnn.config import *
from returnn.util import better_exchook
Expand All @@ -21,16 +20,16 @@ def test_old_format():
)
)

assert_true(config.has("num_inputs"))
assert_true(config.has("hidden_type"))
assert_equal(config.int("num_inputs", -1), 3)
assert_equal(config.value("hidden_type", "x"), "forward,lstm")
assert_equal(config.value("hidden_type", "x", index=0), "forward")
assert_equal(config.value("hidden_type", "x", index=1), "lstm")
assert_equal(config.list("hidden_type", ["x"]), ["forward", "lstm"])
assert config.has("num_inputs") is True
assert config.has("hidden_type") is True
assert config.int("num_inputs", -1) == 3
assert config.value("hidden_type", "x") == "forward,lstm"
assert config.value("hidden_type", "x", index=0) == "forward"
assert config.value("hidden_type", "x", index=1) == "lstm"
assert config.list("hidden_type", ["x"]) == ["forward", "lstm"]

assert_false(config.is_typed("num_inputs"))
assert_false(config.is_typed("hidden_type"))
assert config.is_typed("num_inputs") is False
assert config.is_typed("hidden_type") is False


def test_json_format():
Expand All @@ -47,19 +46,19 @@ def test_json_format():
)
)

assert_true(config.has("num_inputs"))
assert_true(config.has("hidden_type"))
assert_equal(config.int("num_inputs", -1), 3)
assert_equal(config.value("hidden_type", "x"), "forward,lstm")
assert_equal(config.value("hidden_type", "x", index=0), "forward")
assert_equal(config.value("hidden_type", "x", index=1), "lstm")
assert_equal(config.list("hidden_type", ["x"]), ["forward", "lstm"])
assert config.has("num_inputs") is True
assert config.has("hidden_type") is True
assert config.int("num_inputs", -1) == 3
assert config.value("hidden_type", "x") == "forward,lstm"
assert config.value("hidden_type", "x", index=0) == "forward"
assert config.value("hidden_type", "x", index=1) == "lstm"
assert config.list("hidden_type", ["x"]) == ["forward", "lstm"]

assert_true(config.is_typed("num_inputs"))
assert_true(config.is_typed("hidden_type"))
assert_is_instance(config.typed_value("num_inputs"), int)
assert_is_instance(config.typed_value("hidden_type"), list)
assert_equal(config.typed_value("hidden_type"), ["forward", "lstm"])
assert config.is_typed("num_inputs") is True
assert config.is_typed("hidden_type") is True
assert isinstance(config.typed_value("num_inputs"), int)
assert isinstance(config.typed_value("hidden_type"), list)
assert config.typed_value("hidden_type") == ["forward", "lstm"]


def test_py_config():
Expand All @@ -74,19 +73,19 @@ def test_py_config():
)
)

assert_true(config.has("num_inputs"))
assert_true(config.has("hidden_type"))
assert_equal(config.int("num_inputs", -1), 3)
assert_equal(config.value("hidden_type", "x"), "forward,lstm")
assert_equal(config.value("hidden_type", "x", index=0), "forward")
assert_equal(config.value("hidden_type", "x", index=1), "lstm")
assert_equal(config.list("hidden_type", ["x"]), ["forward", "lstm"])
assert config.has("num_inputs") is True
assert config.has("hidden_type") is True
assert config.int("num_inputs", -1) == 3
assert config.value("hidden_type", "x") == "forward,lstm"
assert config.value("hidden_type", "x", index=0) == "forward"
assert config.value("hidden_type", "x", index=1) == "lstm"
assert config.list("hidden_type", ["x"]) == ["forward", "lstm"]

assert_true(config.is_typed("num_inputs"))
assert_true(config.is_typed("hidden_type"))
assert_is_instance(config.typed_value("num_inputs"), int)
assert_is_instance(config.typed_value("hidden_type"), list)
assert_equal(config.typed_value("hidden_type"), ["forward", "lstm"])
assert config.is_typed("num_inputs") is True
assert config.is_typed("hidden_type") is True
assert isinstance(config.typed_value("num_inputs"), int)
assert isinstance(config.typed_value("hidden_type"), list)
assert config.typed_value("hidden_type") == ["forward", "lstm"]


def test_rnn_init_config_py_global_var():
Expand Down Expand Up @@ -115,17 +114,17 @@ def test_func():
assert rnn.config.has("task")
assert rnn.config.has("test_value")
assert rnn.config.has("test_func")
assert_equal(rnn.config.value("task", None), "search")
assert rnn.config.value("task", None) == "search"
assert rnn.config.is_typed("test_value")
assert_equal(rnn.config.typed_value("test_value"), 42)
assert rnn.config.typed_value("test_value") == 42
assert rnn.config.is_typed("test_func")
# So far it's fine.
# Now something a bit strange.
# Earlier, this failed, because the command-line overwrote this.
assert rnn.config.is_typed("task")
test_func = rnn.config.typed_dict["test_func"]
assert callable(test_func)
assert_equal(test_func(), "search")
assert test_func() == "search"


def test_rnn_init_config_py_cmd_type():
Expand All @@ -152,7 +151,7 @@ def test_func():
assert rnn.config.is_typed("test_func")
test_func = rnn.config.typed_dict["test_func"]
assert callable(test_func)
assert_equal(test_func(), 0)
assert test_func() == 0


def test_config_py_ext():
Expand All @@ -176,9 +175,9 @@ def test_func():
assert config.is_typed("test_func")
test_func = config.typed_dict["test_func"]
assert callable(test_func)
assert_equal(test_func(), "train")
assert test_func() == "train"
config.set("task", "search")
assert_equal(test_func(), "search")
assert test_func() == "search"


def test_config_py_old_returnn_imports():
Expand Down
Loading

0 comments on commit 4c6e245

Please sign in to comment.