Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test missing extra requirements?

On a python distribution (Plone related) that I'm developing I added an extra requirement: async

Thus, if someone wants to use it without async features that's fine, but they have also that possibility. Code has already been updated to use it conditionally.

But now the question is: on my test runner I declare my own distribution to install the async extra so I can test the async functionality, but that prevents me from testing the non-async code paths.

How can one handle this?

like image 694
gforcada Avatar asked Sep 13 '26 09:09

gforcada


1 Answers

I see two possibilities:

  • build two test runners with different dependencies installed.

  • if this is not acceptable, you could condition the imports of your optional dependency not only on the availability of the package but also on the value of a global variable. Your test runner could run tests twice with the variable configured on and off.

like image 189
Godefroid Chapelle Avatar answered Sep 14 '26 22:09

Godefroid Chapelle