Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pytest, fixed tests, added tox, added mistune to dependencies #35

Closed
wants to merge 2 commits into from
Closed

Conversation

lunemec
Copy link
Contributor

@lunemec lunemec commented May 1, 2015

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.

@SanketDG
Copy link
Contributor

SanketDG commented May 1, 2015

What is usecase of mistune?

@lunemec
Copy link
Contributor Author

lunemec commented May 1, 2015

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

@lunemec
Copy link
Contributor Author

lunemec commented May 1, 2015

It seems to be dependency for pygments

@lunemec
Copy link
Contributor Author

lunemec commented May 1, 2015

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.

@lunemec
Copy link
Contributor Author

lunemec commented May 1, 2015

OK, i'll remove the mistune dependency.

@lunemec
Copy link
Contributor Author

lunemec commented May 1, 2015

Removed

@jonathanslenders
Copy link
Member

Thanks! I have a look at this later on.

@lepture
Copy link

lepture commented Jun 23, 2015

@lunemec It is an optional dependency of IPython

@tony
Copy link

tony commented May 21, 2016

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

@tony
Copy link

tony commented May 22, 2016

tmux-python/tmuxp@50d576c

Just converted a pretty large test suite from unittest to py.test.

Some things that gave me pause initially:

  • it feels a tad unpythonic at first. There is some monkey-patching involved. There is magic-mojo happening in the background that isn't transparent. e.g.:
    • You create some fixtures in conftest.py, and tests magically get them in their arguments if you put them in the signature.
    • The assert has super powers

Timeline of me switching opinions:

  • about a year ago, had a good python programmer friend recommend it to me a year ago, spoke fondly of 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...
  • a few days ago I was just telling someone this extemporaneously "The other thing is I stick to plain-old unittest on things ATM. Maybe pytest or nose is the way but I want it to play out, I don't want to introduce specialized behavior and 2 yrs later end up having to provide life support to a lib that's unmaintained.": Getting error after installing package? celery/case#1 (comment)
  • around the same time i first read this thread, i didn't respond to it, but i was about to say screw py.test just use unittest for now
  • then, i look at pypa's projects and flask, werkzeug, etc. pytest is everywhere
  • then i as a trial, port tests on a sample project, tmuxp, over to it

Things I fell in love with:

@tony
Copy link

tony commented May 22, 2016

@lunemec can you rebase?

@lunemec
Copy link
Contributor Author

lunemec commented May 23, 2016

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.

@lunemec
Copy link
Contributor Author

lunemec commented May 23, 2016

Rebased.

@tony
Copy link

tony commented May 23, 2016

@lunemec yea no problem.

@jonathanslenders is this ok to put in ? I'd like to start adding tests

@jonathanslenders
Copy link
Member

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.

@tony
Copy link

tony commented May 25, 2016

@jonathanslenders can we get a slack setup for prompt-toolkit, pyvim, ptpython, pymux, etc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants