Opened 15 years ago
Closed 13 years ago
#355 closed defect (fixed)
nose and modules with optional library deps — at Version 6
| Reported by: | Elrond | Owned by: | Elrond |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.3.3 |
| Component: | programming | Keywords: | |
| Cc: | Parent Tickets: |
Description (last modified by )
During unit tests nose imports every *.py it finds in the tree. It does so to search for unit tests there. If the import fails, this gives an error in the final unit test results. For GMG this can fail, because some modules import optional libraries (video for example).
Currently known options:
- Add hard dependencies again for all optional libraries. Not nice, but would solve the problem at hand.
- Rewrite the affected modules to somehow gracefully handle the situation and not error. Not really nice, but acceptable.
- Change runtests.sh to call nose in a way, that tests are only searched in mediagoblin.tests. This seems the nicest way.
Change History (6)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
Update: This affects only __init__.py and modules imported from there. Some random models.py importing say sqlalchemy doesn't trigger this issues on its own.
comment:4 by , 14 years ago
Giving a path to nosetests can easily prevent most of this problem. It tells it to search only for tests in the given directory, like so:
./runtests.sh $PWD/mediagoblin/tests
We could easily modify runtests.sh to add this argument on its own, if no other relevant args are given.
Do we want that?
Are all our tests going to be in mediagoblin/tests? Or are tests for core plugins going to be in their individual directories? Maybe not, because mediagoblin/tests/__init__.py has some setup code for tests.
What do others think?
(hinted by ShawnRisk)
comment:5 by , 14 years ago
| Milestone: | → 0.3.3 |
|---|---|
| Owner: | set to |
| Status: | accepted → assigned |
The above mentioned idea for changing runtests.sh has been implemented by me in 7dec9f92f345df4bb33d399f60c49544c7e60bf6.
In my opinion, we can close this issue. Any vetos? (set milestone to next release, so we revisit it sooner than later for just closing or postponing.)
comment:6 by , 13 years ago
| Description: | modified (diff) |
|---|---|
| Resolution: | → fixed |
| Status: | assigned → closed |
Closed.

Regarding option 2: I haven't found an easy way in python to leave module initialisation early. Like try: import bigvideolibrary except ImportError: leave_module_init_now(). Of course one can do try: import CookCoffeeBase from coffeelib except ImportError: CookCoffeeBase = object and create dummies for all imported things.
Regarding option 3: My quick search a few weeks back did not reveal anything simple either. I hope someone else is more successful.