import os
import pathlib
import unittest

from testbook import testbook

from dffml.util.asynctestcase import AsyncTestCase
from dffml.util.os import chdir

TESTS_PATH = pathlib.Path(__file__).parents[1]
NOTEBOOK_DATA_PATH = TESTS_PATH.joinpath("notebooks", "data")
NB_PATH = TESTS_PATH.parent / "examples" / "notebooks"


class TestNotebook(AsyncTestCase):
    """
    Class to test notebooks.
    Methods are generated in runtime to test notebooks present in `examples/notebooks`.
    """

    REQUIRED_PLUGINS = [
        "dffml-model-scikit",
        "dffml-model-xgboost",
    ]


def mk_notebook_test(path: pathlib.Path):
    def testcase(self):
        with chdir(NOTEBOOK_DATA_PATH):
            with testbook(path, timeout=-1, execute=True) as tb:
                pass

    testcase = unittest.skipIf(
        "TEST_DOCS" not in os.environ,
        "TEST_DOCS environment variable not set",
    )(testcase)

    return testcase


method_base_name = "test_nb_"
# Make dir if it doesn't exist
NOTEBOOK_DATA_PATH.mkdir(parents=True, exist_ok=True)

for path in NB_PATH.glob("*.ipynb"):
    # Create the testcase
    test_case = mk_notebook_test(path)
    # Create the method name
    method_name = method_base_name + path.stem
    # Create the method
    setattr(TestNotebook, method_name, test_case)

5f3d285eb40d4e7569c90272766b19f1afef74c9
<mask token>


class TestNotebook(AsyncTestCase):
    """
    Class to test notebooks.
    Methods are generated in runtime to test notebooks present in `examples/notebooks`.
    """
    REQUIRED_PLUGINS = ['dffml-model-scikit', 'dffml-model-xgboost']


def mk_notebook_test(path: pathlib.Path):

    def testcase(self):
        with chdir(NOTEBOOK_DATA_PATH):
            with testbook(path, timeout=-1, execute=True) as tb:
                pass
    testcase = unittest.skipIf('TEST_DOCS' not in os.environ,
        'TEST_DOCS environment variable not set')(testcase)
    return testcase


<mask token>

<mask token>


class TestNotebook(AsyncTestCase):
    """
    Class to test notebooks.
    Methods are generated in runtime to test notebooks present in `examples/notebooks`.
    """
    REQUIRED_PLUGINS = ['dffml-model-scikit', 'dffml-model-xgboost']


def mk_notebook_test(path: pathlib.Path):

    def testcase(self):
        with chdir(NOTEBOOK_DATA_PATH):
            with testbook(path, timeout=-1, execute=True) as tb:
                pass
    testcase = unittest.skipIf('TEST_DOCS' not in os.environ,
        'TEST_DOCS environment variable not set')(testcase)
    return testcase


<mask token>
NOTEBOOK_DATA_PATH.mkdir(parents=True, exist_ok=True)
for path in NB_PATH.glob('*.ipynb'):
    test_case = mk_notebook_test(path)
    method_name = method_base_name + path.stem
    setattr(TestNotebook, method_name, test_case)

<mask token>
TESTS_PATH = pathlib.Path(__file__).parents[1]
NOTEBOOK_DATA_PATH = TESTS_PATH.joinpath('notebooks', 'data')
NB_PATH = TESTS_PATH.parent / 'examples' / 'notebooks'


class TestNotebook(AsyncTestCase):
    """
    Class to test notebooks.
    Methods are generated in runtime to test notebooks present in `examples/notebooks`.
    """
    REQUIRED_PLUGINS = ['dffml-model-scikit', 'dffml-model-xgboost']


def mk_notebook_test(path: pathlib.Path):

    def testcase(self):
        with chdir(NOTEBOOK_DATA_PATH):
            with testbook(path, timeout=-1, execute=True) as tb:
                pass
    testcase = unittest.skipIf('TEST_DOCS' not in os.environ,
        'TEST_DOCS environment variable not set')(testcase)
    return testcase


method_base_name = 'test_nb_'
NOTEBOOK_DATA_PATH.mkdir(parents=True, exist_ok=True)
for path in NB_PATH.glob('*.ipynb'):
    test_case = mk_notebook_test(path)
    method_name = method_base_name + path.stem
    setattr(TestNotebook, method_name, test_case)

import os
import pathlib
import unittest
from testbook import testbook
from dffml.util.asynctestcase import AsyncTestCase
from dffml.util.os import chdir
TESTS_PATH = pathlib.Path(__file__).parents[1]
NOTEBOOK_DATA_PATH = TESTS_PATH.joinpath('notebooks', 'data')
NB_PATH = TESTS_PATH.parent / 'examples' / 'notebooks'


class TestNotebook(AsyncTestCase):
    """
    Class to test notebooks.
    Methods are generated in runtime to test notebooks present in `examples/notebooks`.
    """
    REQUIRED_PLUGINS = ['dffml-model-scikit', 'dffml-model-xgboost']


def mk_notebook_test(path: pathlib.Path):

    def testcase(self):
        with chdir(NOTEBOOK_DATA_PATH):
            with testbook(path, timeout=-1, execute=True) as tb:
                pass
    testcase = unittest.skipIf('TEST_DOCS' not in os.environ,
        'TEST_DOCS environment variable not set')(testcase)
    return testcase


method_base_name = 'test_nb_'
NOTEBOOK_DATA_PATH.mkdir(parents=True, exist_ok=True)
for path in NB_PATH.glob('*.ipynb'):
    test_case = mk_notebook_test(path)
    method_name = method_base_name + path.stem
    setattr(TestNotebook, method_name, test_case)

import os
import pathlib
import unittest

from testbook import testbook

from dffml.util.asynctestcase import AsyncTestCase
from dffml.util.os import chdir

TESTS_PATH = pathlib.Path(__file__).parents[1]
NOTEBOOK_DATA_PATH = TESTS_PATH.joinpath("notebooks", "data")
NB_PATH = TESTS_PATH.parent / "examples" / "notebooks"


class TestNotebook(AsyncTestCase):
    """
    Class to test notebooks.
    Methods are generated in runtime to test notebooks present in `examples/notebooks`.
    """

    REQUIRED_PLUGINS = [
        "dffml-model-scikit",
        "dffml-model-xgboost",
    ]


def mk_notebook_test(path: pathlib.Path):
    def testcase(self):
        with chdir(NOTEBOOK_DATA_PATH):
            with testbook(path, timeout=-1, execute=True) as tb:
                pass

    testcase = unittest.skipIf(
        "TEST_DOCS" not in os.environ,
        "TEST_DOCS environment variable not set",
    )(testcase)

    return testcase


method_base_name = "test_nb_"
# Make dir if it doesn't exist
NOTEBOOK_DATA_PATH.mkdir(parents=True, exist_ok=True)

for path in NB_PATH.glob("*.ipynb"):
    # Create the testcase
    test_case = mk_notebook_test(path)
    # Create the method name
    method_name = method_base_name + path.stem
    # Create the method
    setattr(TestNotebook, method_name, test_case)
