Make a common testtool wrapper

Registered by Boris Pavlovic on 2013-05-23

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

Mark McLoughlin
Boris Pavlovic
Boris Pavlovic
Series goal:
Accepted for havana
Milestone target:
milestone icon 2013.2
Started by
Boris Pavlovic on 2013-05-23
Completed by
Mark McLoughlin on 2013-08-13

Related branches



Patch proposed here:

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 in oslo-tests to use my 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 (some kind of tests/ to oslo;
1) Replace using tests/ by my file in all tests for oslo;
2) Integrate with each OpenStack component one by one, adding new common fixtures, matchers and other tools; -- a-gorodnev

Gerrit topic:,topic:bp/common-unit-tests,n,z

Addressed by:
    Replace using tests.utils part3

Addressed by:
    Add utils for creating tempfile


Work Items

This blueprint contains Public information 
Everyone can see this information.