Closed lunemec closed 8 years ago
What is usecase of mistune
?
When you try to open file without it, you get this traceback:
Traceback (most recent call last):
File "/usr/local/bin/pyvim", line 9, in <module>
load_entry_point('pyvim==0.0.2', 'console_scripts', 'pyvim')()
File "build/bdist.linux-x86_64/egg/pyvim/entry_points/run_pyvim.py", line 48, in run
File "build/bdist.linux-x86_64/egg/pyvim/editor.py", line 297, in run
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/interface.py", line 321, in read_input
self.eventloop.run(self.stdin, self.create_eventloop_callbacks())
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/eventloop/posix.py", line 67, in run
callbacks.redraw()
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/interface.py", line 632, in redraw
self.cli._redraw()
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/interface.py", line 293, in _redraw
self.renderer.render(self, self.layout, self.style)
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/renderer.py", line 295, in render
extended_height=size.rows,
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/containers.py", line 241, in write_to_screen
self.content.write_to_screen(cli, screen, write_position)
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/containers.py", line 80, in write_to_screen
dimensions = [c.height(cli, write_position.width) for c in self.children]
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/containers.py", line 238, in height
return self.content.height(cli, width)
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/containers.py", line 140, in height
dimensions = [c.height(cli, s) for s, c in zip(sizes, self.children)]
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/containers.py", line 66, in height
dimensions = [c.height(cli, width) for c in self.children]
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/containers.py", line 559, in height
preferred_height = self.content.preferred_height(cli, width)
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/controls.py", line 237, in preferred_height
screen = self.create_screen(cli, width, None)
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/controls.py", line 363, in create_screen
screen, cursor_position_to_xy = self._screen_lru_cache.get(key, _create_screen)
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/controls.py", line 73, in get
value = getter_func()
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/controls.py", line 320, in _create_screen
input_tokens, cursor_transform_functions = self._get_input_tokens(cli, document)
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/controls.py", line 279, in _get_input_tokens
return self._token_lru_cache.get(key, get)
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/controls.py", line 73, in get
value = getter_func()
File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/layout/controls.py", line 252, in get
tokens = list(self.lexer.get_tokens(document.text))
File "build/bdist.linux-x86_64/egg/pyvim/lexer.py", line 35, in get_tokens
File "/usr/local/lib/python2.7/dist-packages/pygments/lexers/__init__.py", line 147, in get_lexer_for_filename
res = find_lexer_class_for_filename(_fn, code)
File "/usr/local/lib/python2.7/dist-packages/pygments/lexers/__init__.py", line 112, in find_lexer_class_for_filename
for cls in find_plugin_lexers():
File "/usr/local/lib/python2.7/dist-packages/pygments/plugin.py", line 53, in find_plugin_lexers
yield entrypoint.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load
['__name__'])
File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/__init__.py", line 3, in <module>
from .exporters import *
File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/exporters/__init__.py", line 1, in <module>
from .export import *
File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/exporters/export.py", line 13, in <module>
from .templateexporter import TemplateExporter
File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/exporters/templateexporter.py", line 30, in <module>
from IPython.nbconvert import filters
File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/filters/__init__.py", line 6, in <module>
from .markdown import *
File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/filters/markdown.py", line 17, in <module>
import mistune
ImportError: No module named mistune
It seems to be dependency for pygments
Ok, so from the traceback, pygments has some plugin capability, and it loads my IPython, and that loads mistune for markdown parsing??? ... this seems to be pygments bug.
OK, i'll remove the mistune dependency.
Removed
Thanks! I have a look at this later on.
@lunemec It is an optional dependency of IPython
Initially I was going to write a disagreement with using pytest.
I was surprised to find that flask and werkzeug, the projects I use at as an inspiration for my prior test suites, have both switched to py.test. pypa/warehouse and pypa/pip is using py.test too...
https://www.youtube.com/watch?v=AiThU6JQbE8
I may trial with py.test a bit with a project of my own and report back
https://github.com/tony/tmuxp/commit/50d576c7b2a8a6b9d075591f3410eba05856e17b
Just converted a pretty large test suite from unittest to py.test.
Some things that gave me pause initially:
assert
has super powersTimeline of me switching opinions:
parametrize
- which I ended up working into a few spots in my example test suite. i looked at it and thought eh, not standard library, and magic...Things I fell in love with:
assert
statement handles dictionaries, lists, etc.tmpdir
factory method, https://pytest.org/latest/tmpdir.html. Also the conveniences inside of the py.path.local
object keep the code light-weight@lunemec can you rebase?
Well, it is not that easy after 1 year. Now my git says: fatal: Needed a single revision which probably means someone did git push --force of this master branch. I may need to cherry-pick those commits for this to work.
Rebased.
@lunemec yea no problem.
@jonathanslenders is this ok to put in ? I'd like to start adding tests
Hi @tony and @lunemec Sorry for the late reply. I merged the two commits. I'm completely in favour of using pytest, and think about converting the tests from prompt-toolkit to pytest as well.
@jonathanslenders can we get a slack setup for prompt-toolkit, pyvim, ptpython, pymux, etc?
I rewrote the test from unittest to pytest and fixed broken tests. Also I added mistune to setup.py, added tox.ini for python's tox package for multiple python versions testing.
However, I suggest dropping support for Python 2.6 and 3.1 these are broken under tox. Python2.6 has somehow broken virtualenv Python3.1 has broken urllib .. Maybe these can be fixed, but I think almost nobody uses these versions of python.