Revision d11c80c0 snf-tools/synnefo_tools/burnin/common.py
b/snf-tools/synnefo_tools/burnin/common.py | ||
---|---|---|
38 | 38 |
|
39 | 39 |
import os |
40 | 40 |
import re |
41 |
import sys |
|
42 | 41 |
import shutil |
42 |
import unittest |
|
43 | 43 |
import datetime |
44 | 44 |
import tempfile |
45 | 45 |
import traceback |
46 |
# Use backported unittest functionality if Python < 2.7 |
|
47 |
try: |
|
48 |
import unittest2 as unittest |
|
49 |
except ImportError: |
|
50 |
if sys.version_info < (2, 7): |
|
51 |
raise Exception("The unittest2 package is required for Python < 2.7") |
|
52 |
import unittest |
|
53 | 46 |
|
54 | 47 |
from kamaki.clients.astakos import AstakosClient |
55 | 48 |
from kamaki.clients.compute import ComputeClient |
... | ... | |
152 | 145 |
# Set test parameters |
153 | 146 |
cls.longMessage = True |
154 | 147 |
|
155 |
def _setattr(self, attr, value): |
|
156 |
"""Used by tests to set an attribute to TestCase |
|
157 |
|
|
158 |
Since each instance of the TestCase will only be used to run a single |
|
159 |
test method (a new fixture is created for each test) the attributes can |
|
160 |
not be saved in the class instance. Instead the class itself should be |
|
161 |
used. |
|
162 |
|
|
163 |
""" |
|
164 |
setattr(self.__class__, attr, value) |
|
165 |
|
|
166 | 148 |
def test_000_clients_setup(self): |
167 | 149 |
"""Initializing astakos/cyclades/pithos clients""" |
168 | 150 |
# Update class attributes |
... | ... | |
494 | 476 |
return type_, val |
495 | 477 |
except ValueError: |
496 | 478 |
return None |
479 |
|
|
480 |
|
|
481 |
class Proper(object): |
|
482 |
"""A descriptor used by tests implementing the TestCase class |
|
483 |
|
|
484 |
Since each instance of the TestCase will only be used to run a single |
|
485 |
test method (a new fixture is created for each test) the attributes can |
|
486 |
not be saved in the class instances. Instead we use descriptors. |
|
487 |
|
|
488 |
""" |
|
489 |
def __init__(self, value=None): |
|
490 |
self.val = value |
|
491 |
|
|
492 |
def __get__(self, obj, objtype=None): |
|
493 |
return self.val |
|
494 |
|
|
495 |
def __set__(self, obj, value): |
|
496 |
self.val = value |
Also available in: Unified diff