Make a common testtool wrapper

Registered by Boris Pavlovic

All project have unit tests, and they own wrappers around testools or unittest or something else.

We should move one of this wrapper to oslo and use it in all projects

Blueprint information

Status:
Complete
Approver:
Mark McLoughlin
Priority:
Medium
Drafter:
Boris Pavlovic
Direction:
Approved
Assignee:
Boris Pavlovic
Definition:
Approved
Series goal:
Accepted for havana
Implementation:
Implemented
Milestone target:
milestone icon 2013.2
Started by
Boris Pavlovic
Completed by
Mark McLoughlin

Related branches

Sprints

Whiteboard

Patch proposed here: https://review.openstack.org/32120

We came to an impass - as also discussed below, it was felt the individual bits of functionality should be added as separate fixtures which projects would consume rather than having a single catch-all base class --- markmc

----

Could you give more information about exactly what the wrappers you're talking about is and how they would be unified? --- markmc

Every Openstack component has wrapper for testtools.Testcase class. Firtstly I get BaseTestCase - the basic class is used across all components. ReplaceModule, APICoverage, TimeOverride are supplementary classes from Nova and are used for compatibility reason. The set of these classes will be increased while integrating with the rest of the projects.

BaseTestCass class from Quantum is similiar to TestClass from Nova. All they do the same work: configure timeouts, I/O capturing, stubbing using mox (moxstubout from oslo is used). The difference only is naming scheme -- Alexander Gorodnev

Consider creating new fixtures like the moxstubout fixtures for each of these use cases. We should be able to choose which of these features we need for a given set of tests rather than having a single giant base class with all the features -- markmc

I'm with markmc -- making the code usable on an opt-in basis rather than creating a base class. unit test base classes are an antipattern for nearly all things they are used for, only deep test plumbing has any reason to be a base class. -- lifeless

I agree with you, the giant base class was really a bad idea, and now I'm working on new patch. New
patch contains the same BaseTestCase class ( wrapper around testtools), but it became smaller and some methods became stand alone functions now. I also changed utils.py in oslo-tests to use my test.py file (I'm not going to commit it right now, it's experemental) and all tests work fine. I've also examined Quantum, Nova and Cinder and found out that all they have some sort of such class or file. Separating this part, we will have to sustain tests-related code in only one place. -- a-gorodnev

My plan:
0) Add initial version of test.py (some kind of tests/utils.py) to oslo;
1) Replace using tests/utils.py by my test.py file in all tests for oslo;
2) Integrate test.py with each OpenStack component one by one, adding new common fixtures, matchers and other tools; -- a-gorodnev

Gerrit topic: https://review.openstack.org/#q,topic:bp/common-unit-tests,n,z

Addressed by: https://review.openstack.org/44424
    Replace using tests.utils part3

Addressed by: https://review.openstack.org/42086
    Add utils for creating tempfile

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.