goodboy / pytest-interactive Goto Github PK
View Code? Open in Web Editor NEWInteractively select tests to run using IPython
Home Page: http://pytest-interactive.readthedocs.org/
License: MIT License
Interactively select tests to run using IPython
Home Page: http://pytest-interactive.readthedocs.org/
License: MIT License
Allow tests and test nodes to be grouped through the + operator something like so
tests_set = tt.tests.some.tests + tt.some.other.tests
The new prompts system in IPython 5.0 renders this unrunnable. Some other issues have prevented me getting a full PR for this, but the gist of what needs to change is that
pm = ipshell.prompt_manager
bold_prmpt = '{color.number}' '{tt}' '{color.prompt}'
pm.in_template = "'{}' selected >>> ".format(bold_prmpt)
# don't rjustify with preceding 'in' prompt
pm.justify = False
Needs to be replaced with the new crap, and the basics for how to replace the input prompt would be to add on to the plugin.py with something like:
from IPython.terminal.prompts import Prompts, Token
...
class PytestPrompt(Prompts):
def in_prompt_tokens(self, cli=None):
return [
(Token.Prompt, '{color.number}'),
(Token.PromptNum, '{tt}'),
(Token.Prompt, ' selected >>> '),
]
class PytestShellEmbed(InteractiveShellEmbed):
"""Custom ip shell with a slightly altered exit message
"""
prompts_class = PytestPrompt
...
I think a syntax like remove 0-4, 23-49
would be more appropriate for sub-test selection using magics. This would allow the user to specify multiple ranges in one command :)
Hi, thanks for your work, I find it superuseful.
Have you think in packaging it for pip? It would be nice to install from there.
$ docker-compose -f docker-compose.yml up
Recreating pctest1 ... done
Attaching to pctest1
pctest1 | ============================= test session starts ==============================
pctest1 | platform linux2 -- Python 2.7.17, pytest-3.3.2, py-1.5.2, pluggy-0.6.0
pctest1 | rootdir: /opt/por/share/p1at/src/p1at/test_mods/sec7, inifile:
pctest1 | plugins: interactive-0.1.4
pctest1 | collected 1 item
pctest1 | INTERNALERROR> Traceback (most recent call last):
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/_pytest/main.py", line 105, in wrap_session
pctest1 | INTERNALERROR> session.exitstatus = doit(config, session) or 0
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/_pytest/main.py", line 142, in _main
pctest1 | INTERNALERROR> config.hook.pytest_collection(session=session)
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/pluggy/__init__.py", line 617, in __call__
pctest1 | INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/pluggy/__init__.py", line 222, in _hookexec
pctest1 | INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/pluggy/__init__.py", line 216, in <lambda>
pctest1 | INTERNALERROR> firstresult=hook.spec_opts.get('firstresult'),
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/pluggy/callers.py", line 201, in _multicall
pctest1 | INTERNALERROR> return outcome.get_result()
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/pluggy/callers.py", line 77, in get_result
pctest1 | INTERNALERROR> _reraise(*ex) # noqa
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/pluggy/callers.py", line 180, in _multicall
pctest1 | INTERNALERROR> res = hook_impl.function(*args)
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/_pytest/main.py", line 152, in pytest_collection
pctest1 | INTERNALERROR> return session.perform_collect()
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/_pytest/main.py", line 685, in perform_collect
pctest1 | INTERNALERROR> config=self.config, items=items)
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/pluggy/__init__.py", line 617, in __call__
pctest1 | INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/pluggy/__init__.py", line 222, in _hookexec
pctest1 | INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/pluggy/__init__.py", line 216, in <lambda>
pctest1 | INTERNALERROR> firstresult=hook.spec_opts.get('firstresult'),
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/pluggy/callers.py", line 201, in _multicall
pctest1 | INTERNALERROR> return outcome.get_result()
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/pluggy/callers.py", line 77, in get_result
pctest1 | INTERNALERROR> _reraise(*ex) # noqa
pctest1 | INTERNALERROR> File "/usr/lib/python2.7/dist-packages/pluggy/callers.py", line 180, in _multicall
pctest1 | INTERNALERROR> res = hook_impl.function(*args)
pctest1 | INTERNALERROR> File "/usr/local/lib/python2.7/dist-packages/interactive/plugin.py", line 28, in pytest_collection_modifyitems
pctest1 | INTERNALERROR> capman.suspendcapture(in_=True)
pctest1 | INTERNALERROR> AttributeError: CaptureManager instance has no attribute 'suspendcapture'
pctest1 |
pctest1 | ========================= no tests ran in 0.86 seconds =========================
pctest1 exited with code 3
(yes some are EoL but our production is about to migrate to newer distro and Py3 :/)
Part of my docker-compose.yml
command: /bin/bash -c "pytest --interactive -s /test.py"
Hey @tgoodlet project looks cool, but it fails to run with pytest 2.9.1.
An attribute error is raised here.
https://github.com/tgoodlet/pytest-interactive/blob/master/interactive/plugin.py#L92
Because _obj
is no longer a member of the instance node
.
Basing these off the pytest unit tests probably makes the most sense. Not sure how to test the magics stuff offhand. Might have to look at the IPython test set.
I just hit
AttributeError: 'DoctestTextfile' object has no attribute '_obj'
Error is in line 102 in plugin.py. item
is an instance of DoctestTextfile
.
My mistake, py.test collected over the documentation folder... but it seems like the collection logic isn't exhaustive.
It would be handy if the embedded scope provided lazy access to all available upstream fixture values for introspection and debugging. Proper considerations should be made for disabling the capturemanager
plugin as well.
@moises-silva mentioned that it would be handy to have a way to get a failed test's id spec from inside the debugger such that you can rerun just that test easily in the next pytest
invocation using that id.
I was thinking we could add a pytest.get_test_id()
or something similar which could aid with this but I'd really love to find a more elegant solution.
See an example algo here:
http://blog.amjith.com/fuzzyfinder-in-10-lines-of-python
Wow, after the last patch release(s) mess I totally screwed up by hard coding the root node name to be pytest
because I was testing against the pytest
source code...
Really need to get CI going for this project...
Using the IPython
tt.test_blah.test_foo?
syntax for quickref-ing docs should give the documentation for all contained test nodes. Currently the TestSet
docs are used which is not so useful. The whole point of this tool is to let you navigate the test set and figure out what you want to run...
I'm trying to install this plugin on python 2.6 and ipython 1.2.1.
i had to take out the requirement in setup.py for ipython because it was trying to upgrade and needless to say, i want to keep the versions i have.
Any help is greatly appreciated.
Thank You
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.