question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Idea: use automatic list of dependencies for pytest display plugin

See original GitHub issue

Currently, the pytest display plugin we have shows a fixed set of packages in the pytest header, and allows other packages using the astropy test runner to configure this. I would like to suggest an alternative which would remove the need for packages to customize this, which is to show the list of all direct dependencies by default. With the following code:

from pkg_resources import working_set


def list_dependency_versions(name):

    pkg = working_set.by_key['astropy']

    requirements = pkg.requires(pkg.extras)

    for req in sorted(requirements, key=lambda x: x.name.lower()):
        if req.name in working_set.by_key:
            req_pkg = working_set.by_key[req.name]
            print(f" {req.name}: {req_pkg.version}")
        else:
            print(f" {req.name}: Not installed")


list_dependency_versions('astropy')

I can get:

 asdf: Not installed
 beautifulsoup4: 4.7.1
 bintrees: Not installed
 bleach: 3.1.0
 bottleneck: 1.2.1
 coverage: Not installed
 h5py: 2.9.0
 html5lib: Not installed
 ipython: 7.5.0
 ipython: 7.5.0
 jplephem: Not installed
 matplotlib: 3.1.0
 mpmath: 1.1.0
 numpy: 1.16.4
 objgraph: Not installed
 pandas: 0.24.2
 pytest: 4.6.2
 pytest-astropy: 0.5.0
 pytest-mpl: Not installed
 pytest-xdist: Not installed
 pytz: 2019.1
 PyYAML: Not installed
 scikit-image: Not installed
 scipy: 1.3.0
 skyfield: Not installed
 sortedcontainers: Not installed
 sphinx-astropy: Not installed

We could still keep the option to override this in other packages if we want, but at least this should make it so that in practice it should never be needed - and we could actually remove it from the package template and just document how to do it in the package-template docs since it should be rare. If people are on board with the idea, I could update the pytest display plugin to do something like this.

(related thought: is there a reason the display plugin is still in astropy rather than a plugin package?)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:27 (27 by maintainers)

github_iconTop GitHub Comments

1reaction
astrofrogcommented, Jun 19, 2019

I’m guilty of this sometimes. I rely on astropy to pull in numpy for me. sweat_smile

For me that’s an argument for the automated list - as then people might fix this kind of outrageous behavior!

1reaction
astrofrogcommented, Jun 18, 2019

Just copy/paste into python session 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plugin List — pytest documentation
name summary last release status requi... pytest‑accept A pytest‑plugin for updating doctest outputs Jan 07, 2022 N/A pytes... pytest‑addons‑test 用于测试pytest的插件 Aug 02, 2021 N/A pytes... pytest‑aio...
Read more >
Manage dependencies using requirements.txt | IntelliJ IDEA ...
Press Ctrl+Alt+S to open project Settings/Preferences. Go to Editor | Inspections. In the list of the inspections, select Unsatisfied package requirements.
Read more >
Pytest Plugins to Love - Towards Data Science
In this article, I'll show you examples of plugins I use and the plugins I found while writing this article. You might want...
Read more >
pytest Documentation - Read the Docs
2.17 How to use pytest with an existing test suite . ... Plugin List . ... fixture mechanism which leverages the concept of...
Read more >
Effective Python Testing With Pytest
pytest is a feature-rich, plugin-based ecosystem for testing your Python code. If you haven't had the pleasure of using pytest yet, then you're ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found