diff --git a/.vscode/settings.json b/.vscode/settings.json index 9b388533a..f04d5500c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,6 +2,13 @@ "python.testing.pytestArgs": [ "tests" ], - "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true + "python.testing.unittestEnabled": true, + "python.testing.pytestEnabled": false, + "python.testing.unittestArgs": [ + "-v", + "-s", + "./t3", + "-p", + "test_*.py" + ] } \ No newline at end of file diff --git a/tests/test_flux.py b/tests/test_flux.py index d5b62091b..6933a08b1 100644 --- a/tests/test_flux.py +++ b/tests/test_flux.py @@ -510,6 +510,26 @@ def test_almost_equal(): assert almost_equal(1e-5, 1e-6, ratio=100) assert almost_equal(1e-6, 1e-5, ratio=100) +def test_closest_bigger_number(): + """Test getting closest bigger number and its index from a list.""" + # Test case 1 + num, i = flux.closest_bigger_number([1, 2, 2.5, 3, 3.5, 4.5, 5], 3.7) + assert num == 4.5 + assert i == 5 + print("\npassed test case 1") + + # Test case 2 + num, i = flux.closest_bigger_number([1, 2, 2.5, 3, 3.5, 4.5, 5], 5.5) + assert num is None + assert i is None + print("passed test case 2") + + # Test case 3 + num, i = flux.closest_bigger_number([1, 2, 2.5, 3, 3.5, 4.5, 5], 0.5) + assert num == 1 + assert i == 0 + print("passed test case 3") + def teardown_module(): """teardown any state that was previously setup with a setup_module method."""