Source code for test_util

"""Test functions of ."""

import pytest

from cobra.util import AutoVivification, format_long_string, show_versions

    "input_string, expected_string",
                "This is a really long string, but is it long enough. "
                "I hope it is long enough so that format_long_string() function works."
            "This is a really long string, but is it long...",
        ("This is short string.", "This is short string."),
[docs] ], ) def test_format_long_string(input_string: str, expected_string: str) -> None: """Test functionality of format long string.""" assert expected_string == format_long_string(input_string)
[docs]def test_autovivification() -> None: """Test proper functionality of autovivification.""" test_data = AutoVivification() test_data["a"]["b"] = 1 test_data["c"]["d"] = 2 assert test_data["a"] == {"b": 1} assert test_data["c"] == {"d": 2} assert test_data["a"]["b"] == 1 assert test_data["c"]["d"] == 2
[docs]def test_show_versions(capsys) -> None: """Test output of dependency information.""" show_versions() captured = capsys.readouterr() lines = captured.out.split("\n") assert lines[1].startswith("System Information") assert lines[2].startswith("==================") assert lines[3].startswith("OS") assert lines[4].startswith("OS-release") assert lines[5].startswith("Python") assert lines[7].startswith("Package Versions") assert lines[8].startswith("================")