Module testlib_verifier.

10. verify_lib

The verify_lib function checks whether the code under test is from the expected test library. For unit test, the source is normally tested in place in the source library. For function test, however, the desired method is to build the code using the project.toml and then test the code from the build target library. When using tox to do the test, this library is placed in the .tox folder. By default, verify_lib will check that code comes from the library in the .tox folder by simply searching for the string “.tox” in the file path for the library. The library path is obtained using ‘’inspect.getsourcefile()’’ for an imported object passed in the call to verify_lib. Note that the string to search for can also be specified in case some other test library is used that does not have “.tox” in the path.

Example1:

pytest test case to ensure the correct library:

from scottbrian_utils.testlib_verifier import verify_lib
from scottbrian_utils.diag_msg import diag_msg
import logging
import os

class TestDiagMsgCorrectLib:
    def test_diag_msg_correct_lib(self) -> None:
        if "TOX_ENV_NAME" in os.environ:
            a_path = verify_lib(obj_to_check=diag_msg)