Package: lib-detect-testenv
lib_detect_testenvVersion v2.0.8 as of 2023-07-14 seeChangelogdetects test environments: pytest, doctest and pycharm docrunnerautomated tests, Github Actions, Documentation, Badges, etc. are managed withPizzaCutter(cookiecutter on steroids)Python version required: 3.8.0 or newertested on recent linux with python 3.8, 3.9, 3.10, 3.11, 3.12-dev, pypy-3.9, pypy-3.10 - architectures: amd64100% code coverage, flake8 style checking ,mypy static type checking ,tested underLinux, macOS, Windows, automatic daily builds and monitoringTry it OnlineUsageUsage from CommandlineInstallation and UpgradeRequirementsAcknowledgementsContributeReport IssuesPull RequestCode of ConductLicenseChangelogTry it OnlineYou might try it right away in Jupyter Notebook by using the “launch binder” badge, or clickhereUsagedetect if test environment is activedefis_testenv_active(arg_string:Optional[str]=None)->bool:"""
    returns True if test environment is detected ("pytest", "doctest", "setup.py test")


    Parameter
    ----------
    arg_string  : optional, if None : str(sys.argv())


    Result
    ----------
    True if Test environment is detected


    Exceptions
    ----------
    none


    Examples
    ----------

    >>> assert is_testenv_active() == True
    """detect if doctest is activedefis_doctest_active(arg_string:Optional[str]=None)->bool:"""
    returns True if pycharm "docrunner.py" or "doctest.py" is detected


    Parameter
    ----------
    arg_string  : optional, if None : str(sys.argv())


    Result
    ----------
    True if docrunner is detected


    Exceptions
    ----------
    none

    >>> assert False == is_doctest_active(arg_string="")
    >>> assert True == is_doctest_active(arg_string="docrunner.py")
    >>> assert True == is_doctest_active(arg_string="doctest.py")

    """detect if pytest is activedefis_pytest_active(arg_string:Optional[str]=None)->bool:"""
    returns True if "pytest" is detected


    Parameter
    ----------
    arg_string  : optional, if None : str(sys.argv())


    Result
    ----------
    True if pytest is detected


    Exceptions
    ----------
    none

    >>> assert True == is_pytest_active(arg_string='pytest.py')
    >>> assert True == is_pytest_active(arg_string='/pytest/__main__.py')

    """detect if setup.py is activedefis_setup_active(arg_string:Optional[str]=None)->bool:"""
    returns True if "setup.py" is detected


    Parameter
    ----------
    arg_string  : optional, if None : str(sys.argv())


    Result
    ----------
    True if setup.py is detected


    Exceptions
    ----------
    none

    >>> assert False == is_setup_active(arg_string="")
    >>> assert True == is_setup_active(arg_string="setup.py")

    """detect if “setup.py test” is activedefis_setup_test_active(arg_string:Optional[str]=None)->bool:"""
    returns True if "setup.py test" is detected


    Parameter
    ----------
    arg_string  : optional, if None : str(sys.argv())


    Result
    ----------
    True if "setup.py test" is detected


    Exceptions
    ----------
    none

    >>> assert False == is_setup_test_active('')
    >>> assert False == is_setup_test_active('setup.py')
    >>> assert True == is_setup_test_active('setup.py test')

    """add a path to the syspathdefadd_path_to_syspath(path_to_append:PathLikeOrString)->None:"""
    adds a path to the syspath

    Parameter
    ----------
    path_to_append
        the path to append - will be resolved by this function and added to syspath
        if path_to_append is a file, its parent directory will be added.


    Result
    ----------
    none


    Exceptions
    ----------
    none


    Examples
    ----------

    >>> add_path_to_syspath(pathlib.Path(__file__).parent)
    >>> path1 = str(sys.path)
    >>> add_path_to_syspath(pathlib.Path(__file__))
    >>> path2 = str(sys.path)
    >>> assert path1 == path2
    """put this in Your__init__.pyto automatically add the package directory to the syspath if the test environment is active.
This is useful for local testing of packages.# __init__.py :# this should be Your first import in __init__fromlib_detect_testenvimport*ifis_testenv_active():add_path_to_syspath(__file__)Usage from Commandlinethere are no cli commandsInstallation and UpgradeBefore You start, its highly recommended to update pip and setup tools:python -m pip --upgrade pip
python -m pip --upgrade setuptoolsto install the latest release from PyPi via pip (recommended):python -m pip install --upgrade lib_detect_testenvto install the latest release from PyPi via pip, including test dependencies:python -m pip install --upgrade lib_detect_testenv[test]to install the latest version from github via pip:python -m pip install --upgrade git+https://github.com/bitranox/lib_detect_testenv.gitinclude it into Your requirements.txt:# Insert following line in Your requirements.txt:
# for the latest Release on pypi:
lib_detect_testenv

# for the latest development version :
lib_detect_testenv @ git+https://github.com/bitranox/lib_detect_testenv.git

# to install and upgrade all modules mentioned in requirements.txt:
python -m pip install --upgrade -r /<path>/requirements.txtto install the latest development version, including test dependencies from source code:# cd ~
$ git clone https://github.com/bitranox/lib_detect_testenv.git
$ cd lib_detect_testenv
python -m pip install -e .[test]via makefile:
makefiles are a very convenient way to install. Here we can do much more,
like installing virtual environments, clean caches and so on.# from Your shell's homedirectory:$gitclonehttps://github.com/bitranox/lib_detect_testenv.git$cdlib_detect_testenv# to run the tests:$maketest# to install the package$makeinstall# to clean the package$makeclean# uninstall the package$makeuninstallRequirementsfollowing modules will be automatically installed :## Project RequirementsAcknowledgementsspecial thanks to “uncle bob” Robert C. Martin, especially for his books on “clean code” and “clean architecture”ContributeI would love for you to fork and send me pull request for this project.
-please ContributeLicenseThis software is licensed under theMIT license—Changelognew MAJOR version for incompatible API changes,new MINOR version for added functionality in a backwards compatible mannernew PATCH version for backwards compatible bug fixesv2.0.82023-07-14:remove dependency clickremove dependency cli_exit_tools to avoid circular dependencyv2.0.72023-07-14:add codeql badgemove 3rd_party_stubs outside the src directoryadd pypy 3.10 testsadd python 3.12-dev testsv2.0.62023-07-13:require minimum python 3.8remove python 3.7 testsv2.0.52023-07-11:introduce PEP517 packaging standardintroduce pyproject.toml build-systemremove mypy.iniremove pytest.iniremove setup.cfgremove setup.pyremove .bettercodehub.ymlremove .travis.ymlupdate black configclean ./tests/test_cli.pyv2.0.42023-06-26: suppress upload of .egg files to pypi.orgv2.0.32023-01-13:update github actions :checkout@v3andsetup-python@v4remove “better code” badgesremove python 3.6 testsadd python 3.11 testsupdate to pypy 3.9 testsv2.0.2.22022-06-02: update to github actionscheckout@v3andsetup-python@v3v2.0.2.12022-06-01: update github actions test matrixv2.0.22022-03-29: remedy mypy Untyped decorator makes function “cli_info” untypedv2.0.12022-03-25: fix github actions windows testv2.0.02021-11-23:add “setup.py test” detectionv1.0.22021-11-22:remove second github action ymlfix “setup.py test”v1.0.12021-11-21: implement github actionsv1.0.02021-11-19: initial release