pete88b / decision_tree

An nbdev test project and decision tree ensemble implementation (see: http://course18.fast.ai)
https://pete88b.github.io/decision_tree/
Apache License 2.0
1 stars 1 forks source link

test_nbs.py issue #3

Open michaelaye opened 3 years ago

michaelaye commented 3 years ago

Hi I'm trying to use your test_nbs.py script to create a coverage report but it fails here:

https://github.com/pete88b/decision_tree/blob/master/test_nbs.py#L109

Config().nbs_path is just a string object, so it wouldn't have a glob attribute?

Here's the pytest output:

$ pytest --cov=planetarypy                                                                                                                           (py38) 
/home/maye/miniconda3/envs/py38/lib/python3.8/site-packages/pep8.py:110: FutureWarning: Possible nested set at position 1
  EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
=================================================================== test session starts ====================================================================
platform linux -- Python 3.8.10, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /home/maye/Dropbox/src/nbplanetary
plugins: nbval-0.9.6, pep8-1.0.6, anyio-3.2.1, cov-2.12.1
collected 1 item                                                                                                                                           

test_nbs.py F                                                                                                                                        [100%]Coverage.py warning: No data was collected. (no-data-collected)

========================================================================= FAILURES =========================================================================
_________________________________________________________________________ test_run _________________________________________________________________________

    def test_run():
        # now we can "nbdev_test_nbs" and have our "before test" callback called
        # nbdev_test_nbs('00_core.ipynb') # Use this line to test a single notebook
>       nbdev_test_nbs()

test_nbs.py:128: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

fname = None, flags = None, n_workers = None, verbose = True, timing = False

    def nbdev_test_nbs(fname=None,flags=None,n_workers=None,verbose=True,timing=False):
        """
        fname:Param("A notebook name or glob to convert", str)=None,
        flags:Param("Space separated list of flags", str)=None,
        n_workers:Param("Number of workers to use", int)=None,
        verbose:Param("Print errors along the way", bool)=True,
        timing:Param("Timing each notebook to see the ones are slow", bool)=False
        """
        "Test in parallel the notebooks matching `fname`, passing along `flags`"
        if flags is not None: flags = flags.split(' ')
        if fname is None:
>           files = [f for f in Config().nbs_path.glob('*.ipynb') if not f.name.startswith('_')]
E           AttributeError: 'str' object has no attribute 'glob'

test_nbs.py:109: AttributeError
puhazoli commented 3 years ago

In order for the script to run with the latest release of nbdev, the Config class's init arguments need to be added, so you should replace (in L109 and L114) Config().nbs_path with Config(".","your_library").config_path and the tests will run.