From bd4578a39582a4ec3c0e76832ac76a164b30be7b Mon Sep 17 00:00:00 2001
From: Samuel Gaist <samuel.gaist@idiap.ch>
Date: Thu, 14 Mar 2019 17:25:20 +0100
Subject: [PATCH] [test][test_experiment_loading] Code cleanup

---
 beat/core/test/test_experiment_loading.py | 72 +++++++++++++----------
 1 file changed, 41 insertions(+), 31 deletions(-)

diff --git a/beat/core/test/test_experiment_loading.py b/beat/core/test/test_experiment_loading.py
index 51ad5449..311ee32f 100644
--- a/beat/core/test/test_experiment_loading.py
+++ b/beat/core/test/test_experiment_loading.py
@@ -46,85 +46,95 @@ def test_load_valid_experiment():
 
     experiment = Experiment(prefix, "user/integers_addition/1/integers_addition")
 
-    assert experiment.valid, "\n  * %s" % "\n  * ".join(experiment.errors)
+    nose.tools.assert_true(
+        experiment.valid, "\n  * %s" % "\n  * ".join(experiment.errors)
+    )
     nose.tools.eq_(experiment.label, "user/user/integers_addition/1/integers_addition")
 
-    assert experiment.toolchain.valid, "\n  * %s" % "\n  * ".join(
-        experiment.toolchain.errors
+    nose.tools.assert_true(
+        experiment.toolchain.valid,
+        "\n  * %s" % "\n  * ".join(experiment.toolchain.errors),
     )
     nose.tools.eq_(experiment.toolchain.name, "user/integers_addition/1")
 
     nose.tools.eq_(len(experiment.datasets), 1)
-    assert "integers" in experiment.datasets
+    nose.tools.assert_true("integers" in experiment.datasets)
     nose.tools.eq_(len(experiment.databases), 1)
     nose.tools.eq_(len(experiment.blocks), 1)
     nose.tools.eq_(len(experiment.analyzers), 1)
 
     nose.tools.eq_(len(experiment.algorithms), 2)
-    assert "user/sum/1" in experiment.algorithms
-    assert experiment.algorithms["user/sum/1"].valid
-    assert "user/integers_analysis/1" in experiment.algorithms
-    assert experiment.algorithms["user/integers_analysis/1"].valid
+    nose.tools.assert_true("user/sum/1" in experiment.algorithms)
+    nose.tools.assert_true(experiment.algorithms["user/sum/1"].valid)
+    nose.tools.assert_true("user/integers_analysis/1" in experiment.algorithms)
+    nose.tools.assert_true(experiment.algorithms["user/integers_analysis/1"].valid)
 
 
 def test_load_one_dataset_two_blocks_toolchain():
 
     experiment = Experiment(prefix, "user/integers_addition/2/integers_addition")
-    assert experiment.valid, "\n  * %s" % "\n  * ".join(experiment.errors)
+    nose.tools.assert_true(
+        experiment.valid, "\n  * %s" % "\n  * ".join(experiment.errors)
+    )
     nose.tools.eq_(experiment.label, "user/user/integers_addition/2/integers_addition")
 
-    assert experiment.toolchain.valid, "\n  * %s" % "\n  * ".join(
-        experiment.toolchain.errors
+    nose.tools.assert_true(
+        experiment.toolchain.valid,
+        "\n  * %s" % "\n  * ".join(experiment.toolchain.errors),
     )
     nose.tools.eq_(experiment.toolchain.name, "user/integers_addition/2")
 
     nose.tools.eq_(len(experiment.datasets), 1)
-    assert "integers" in experiment.datasets
+    nose.tools.assert_true("integers" in experiment.datasets)
     nose.tools.eq_(len(experiment.databases), 1)
     nose.tools.eq_(len(experiment.blocks), 2)
     nose.tools.eq_(len(experiment.analyzers), 1)
 
     nose.tools.eq_(len(experiment.algorithms), 2)
-    assert "user/sum/1" in experiment.algorithms
-    assert experiment.algorithms["user/sum/1"].valid
-    assert "user/integers_analysis/1" in experiment.algorithms
-    assert experiment.algorithms["user/integers_analysis/1"].valid
+    nose.tools.assert_true("user/sum/1" in experiment.algorithms)
+    nose.tools.assert_true(experiment.algorithms["user/sum/1"].valid)
+    nose.tools.assert_true("user/integers_analysis/1" in experiment.algorithms)
+    nose.tools.assert_true(experiment.algorithms["user/integers_analysis/1"].valid)
 
 
 def test_load_two_datasets_three_blocks_toolchain():
 
     experiment = Experiment(prefix, "user/integers_addition/3/integers_addition")
-    assert not experiment.valid
+    nose.tools.assert_false(experiment.valid)
     nose.tools.eq_(experiment.label, "user/user/integers_addition/3/integers_addition")
-    assert experiment.errors[0].find("mismatch in input/output") != -1
+    nose.tools.assert_not_equal(
+        experiment.errors[0].find("mismatch in input/output"), -1
+    )
 
-    assert experiment.toolchain.valid
+    nose.tools.assert_true(experiment.toolchain.valid)
     nose.tools.eq_(experiment.toolchain.name, "user/integers_addition/3")
 
     nose.tools.eq_(len(experiment.datasets), 2)
-    assert "integers1" in experiment.datasets
-    assert "integers2" in experiment.datasets
+    nose.tools.assert_true("integers1" in experiment.datasets)
+    nose.tools.assert_true("integers2" in experiment.datasets)
     nose.tools.eq_(len(experiment.databases), 1)
     nose.tools.eq_(len(experiment.blocks), 3)
     nose.tools.eq_(len(experiment.analyzers), 1)
 
     nose.tools.eq_(len(experiment.algorithms), 2)
-    assert "user/sum/1" in experiment.algorithms
-    assert experiment.algorithms["user/sum/1"].valid
-    assert "user/integers_analysis/1" in experiment.algorithms
-    assert experiment.algorithms["user/integers_analysis/1"].valid
+    nose.tools.assert_true("user/sum/1" in experiment.algorithms)
+    nose.tools.assert_true(experiment.algorithms["user/sum/1"].valid)
+    nose.tools.assert_true("user/integers_analysis/1" in experiment.algorithms)
+    nose.tools.assert_true(experiment.algorithms["user/integers_analysis/1"].valid)
 
 
 def test_no_description():
 
     experiment = Experiment(prefix, "user/integers_addition/1/integers_addition")
-    assert experiment.valid, "\n  * %s" % "\n  * ".join(experiment.errors)
-    assert experiment.description is None
-    assert experiment.documentation is None
+    nose.tools.assert_true(
+        experiment.valid, "\n  * %s" % "\n  * ".join(experiment.errors)
+    )
+    nose.tools.assert_is_none(experiment.description)
+    nose.tools.assert_is_none(experiment.documentation)
 
     description = "This is my descriptor"
     experiment.description = description
-    assert isinstance(experiment.description, six.string_types)
+    nose.tools.assert_true(isinstance(experiment.description, six.string_types))
     nose.tools.eq_(experiment.description, description)
 
 
@@ -133,10 +143,10 @@ def test_export():
 
     name = "user/integers_addition/1/integers_addition"
     obj = Experiment(prefix, name)
-    assert obj.valid, "\n  * %s" % "\n  * ".join(obj.errors)
+    nose.tools.assert_true(obj.valid, "\n  * %s" % "\n  * ".join(obj.errors))
 
     obj.export(tmp_prefix)
 
     # load from tmp_prefix and validates
     exported = Experiment(tmp_prefix, name)
-    assert exported.valid, "\n  * %s" % "\n  * ".join(exported.errors)
+    nose.tools.assert_true(exported.valid, "\n  * %s" % "\n  * ".join(exported.errors))
-- 
GitLab