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.

Consider using pytest.importorskip('dependency') in testing

See original GitHub issue

There is a helper function in pytest importorskip that might help clean up testing code. This would generally replace something like @skipif('not HAS_DEPENDENCY') with a line inside the test function / method dependency = pytest.importorskip('dependency').

I’m not completely sure this is an overall win, but we should think about this as a new standard idiom.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:20 (20 by maintainers)

github_iconTop GitHub Comments

2reactions
cdeilcommented, Dec 7, 2016

I’ve written to the testing-in-python list about this, the thread starts here: http://lists.idyll.org/pipermail/testing-in-python/2016-December/006962.html

I’ll post here again in a few days with a summary / recommendation on how to proceed.

Still, opinions welcome of course here in the meantime what you’d prefer to have for Astropy core!

2reactions
taldcroftcommented, Dec 2, 2016

“You can use the following import helper at module level or within a test or test setup function:”

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use skip and xfail to deal with tests that cannot succeed
Skipping on a missing import dependency¶. You can skip tests on a missing import by using pytest.importorskip at module level, within a test,...
Read more >
pytest-dependency 0.5.1 documentation - Read the Docs
Consider the following example test module: import pytest @pytest.mark.dependency() ... All the tests are decorated with pytest.mark.dependency() .
Read more >
pytest Documentation - Read the Docs
Skipping on a missing import dependency. You can skip tests on a missing import by using pytest.importorskip at module level, within a test, ......
Read more >
[TIP] Add pytest requires_dependency decorator in addition to ...
[TIP] Add pytest requires_dependency decorator in addition to importorskip? ... have a lot of tests (using pytest) that require optional dependencies.
Read more >
Reference — pytest documentation
It will also override any fixture-function defined scope, allowing to set a dynamic scope using test context or configuration. pytest.mark.skip¶. Tutorial: ...
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