def test_python_execution_with_OO() -> None:
    ''' Running python with -OO will discard docstrings (__doc__ is None)
    which can cause problems if docstrings are naively formatted.

    This test ensures that the all modules are importable, even with -OO set.

    If you encounter a new problem with docstrings being formatted, try
    using format_docstring.
    '''
    imports = [f"import {mod}" for mod in ls_modules(skip_prefixes=SKIP)]

    proc = Popen([python, "-OO", "-"], stdout=PIPE, stdin=PIPE)
    proc.communicate("\n".join(imports).encode("utf-8"))
    proc.wait()

    assert proc.returncode == 0, "Execution with -OO failed"
예제 #2
0
from subprocess import run
from sys import executable as python

# Bokeh imports
from bokeh._testing.util.project import ls_modules, verify_clean_imports

#-----------------------------------------------------------------------------
# Tests
#-----------------------------------------------------------------------------

SELENIUM_ALLOWED = (
    "bokeh._testing",
    "bokeh.io.webdriver",
)

MODULES = ls_modules(skip_prefixes=SELENIUM_ALLOWED)

# This test takes a long time to run, but if the combined test fails then
# uncommenting it will locate exactly what module(s) are the problem
# @pytest.mark.parametrize('module', MODULES)
# def test_no_selenium_common_individual(module) -> None:
#     proc = run([python, "-c", verify_clean_imports('selenium', [module])])
#     assert proc.returncode == 0, f"Selenium imported in common module {module}"


def test_no_selenium_common_combined() -> None:
    ''' Basic usage of Bokeh should not result in any Selenium code being
    imported. This test ensures that importing basic modules does not bring in
    Tornado.

    '''
# Standard library imports
from subprocess import run
from sys import executable as python

# Bokeh imports
from bokeh._testing.util.project import ls_modules, verify_clean_imports

#-----------------------------------------------------------------------------
# Tests
#-----------------------------------------------------------------------------

# There should not be unprotected IPython imports /anywhere/
IPYTHON_ALLOWED = ("bokeh._testing", )

MODULES = ls_modules(skip_prefixes=IPYTHON_ALLOWED)

# This test takes a long time to run, but if the combined test fails then
# uncommenting it will locate exactly what module(s) are the problem
# @pytest.mark.parametrize('module', MODULES)
# def test_no_ipython_common_individual(module) -> None:
#     proc = run([python, "-c", verify_clean_imports('IPython', [module])])
#     assert proc.returncode == 0, f"IPython imported in common module {module}"


def test_no_ipython_common_combined() -> None:
    ''' Basic usage of Bokeh should not result in any IPython code being
    imported. This test ensures that importing basic modules does not bring in
    IPython.

    '''
예제 #4
0
from bokeh._testing.util.project import ls_modules, verify_clean_imports

#-----------------------------------------------------------------------------
# Tests
#-----------------------------------------------------------------------------

TORNADO_ALLOWED = (
    "bokeh._testing",
    "bokeh.client",
    "bokeh.command",
    "bokeh.io.notebook",
    "bokeh.server",
    "bokeh.util.tornado",
)

MODULES = ls_modules(skip_prefixes=TORNADO_ALLOWED)

# This test takes a long time to run, but if the combined test fails then
# uncommenting it will locate exactly what module(s) are the problem
# @pytest.mark.parametrize('module', MODULES)
# def test_no_tornado_common_individual(module) -> None:
#     proc = run([python, "-c", verify_clean_imports('tornado', [module])])
#     assert proc.returncode == 0, f"Tornado imported in common module {module}"

def test_no_tornado_common_combined() -> None:
    ''' Basic usage of Bokeh should not result in any Tornado code being
    imported. This test ensures that importing basic modules does not bring in
    Tornado.

    '''
    proc = run([python, "-c", verify_clean_imports('tornado', MODULES)])
예제 #5
0
# Bokeh imports
from bokeh._testing.util.project import ls_modules, verify_clean_imports

#-----------------------------------------------------------------------------
# Tests
#-----------------------------------------------------------------------------

# There should not be unprotected pandas imports /anywhere/
PANDAS_ALLOWED = (
    "bokeh.sampledata",
    "bokeh.sphinxext",
    "bokeh._testing",
)

MODULES = ls_modules(skip_prefixes=PANDAS_ALLOWED)

# This test takes a long time to run, but if the combined test fails then
# uncommenting it will locate exactly what module(s) are the problem
# @pytest.mark.parametrize('module', MODULES)
# def test_no_pandas_common_individual(module) -> None:
#     proc = run([python, "-c", verify_clean_imports('pandas', [module])])
#     assert proc.returncode == 0, f"pandas imported in common module {module}"


def test_no_pands_common_combined() -> None:
    ''' In order to keep the initial import times reasonable,  import
    of Bokeh should not result in any Pandas code being imported. This
    test ensures that importing basic modules does not bring in pandas.

    '''