akaihola / ipython_pytest

Pytest magic for IPython notebooks
Other
37 stars 8 forks source link

Add an optional working directory argument #3

Open akaihola opened 2 years ago

akaihola commented 2 years ago

Fixes #2

patrickkidd commented 2 years ago

With this notebook:

%load_ext ipython_pytest
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-e78da3b5deff> in <module>
----> 1 get_ipython().run_line_magic('load_ext', 'ipython_pytest')
      2 
      3 import sys
      4 for i in sys.path:
      5     print(i)

~/dev/teamworks/.direnv/python-3.7.5/lib/python3.7/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2325                 kwargs['local_ns'] = self.get_local_scope(stack_depth)
   2326             with self.builtin_trap:
-> 2327                 result = fn(*args, **kwargs)
   2328             return result
   2329 

~/dev/teamworks/.direnv/python-3.7.5/lib/python3.7/site-packages/decorator.py in fun(*args, **kw)
    230             if not kwsyntax:
    231                 args, kw = fix(args, kw, sig)
--> 232             return caller(func, *(extras + args), **kw)
    233     fun.__name__ = func.__name__
    234     fun.__doc__ = func.__doc__

~/dev/teamworks/.direnv/python-3.7.5/lib/python3.7/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

~/dev/teamworks/.direnv/python-3.7.5/lib/python3.7/site-packages/IPython/core/magics/extension.py in load_ext(self, module_str)
     31         if not module_str:
     32             raise UsageError('Missing module name.')
---> 33         res = self.shell.extension_manager.load_extension(module_str)
     34 
     35         if res == 'already loaded':

~/dev/teamworks/.direnv/python-3.7.5/lib/python3.7/site-packages/IPython/core/extensions.py in load_extension(self, module_str)
     79                 with prepended_to_syspath(self.ipython_extension_dir):
     80                     mod = import_module(module_str)
---> 81                     if mod.__file__.startswith(self.ipython_extension_dir):
     82                         print(("Loading extensions from {dir} is deprecated. "
     83                                "We recommend managing extensions like any "

AttributeError: 'NoneType' object has no attribute 'startswith'
akaihola commented 2 years ago

Strange. Are you sure you did pip install . or pip install -e . in the ipython_pytest repository root directory in the environment which you run Jupyter in?

Could you verify that either one of these files exist after doing the pip install: