~bac/lpsetup/lxc-integration

« back to all changes in this revision

Viewing changes to lpsetup/tests/integration/common.py

  • Committer: Brad Crittenden
  • Date: 2012-07-19 18:24:13 UTC
  • Revision ID: bac@canonical.com-20120719182413-n4sztm99afr0b7s0
Added proper arg parsing

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
    'IntegrationTestBase',
10
10
    ]
11
11
 
 
12
import argparse
 
13
 
12
14
 
13
15
class IntegrationTestBase:
14
16
 
15
17
    banner_width = 70
16
18
    test_type = None
17
19
 
18
 
    def __init__(self, args):
19
 
        self.args = args
 
20
    def __init__(self):
 
21
        self.parser = argparse.ArgumentParser()
 
22
        self.parser.add_argument('--no-tear-down', action='store_true',
 
23
                                 default=False,
 
24
                                 help='Do not run the tear down method for debugging.')
 
25
        self.args = self.parser.parse_args()
20
26
 
21
27
    def banner(self, msg, width=banner_width):
22
28
        print '*' * width
50
56
                self.banner('Test succeeded.')
51
57
                return 0
52
58
        finally:
53
 
            if '--no-tear-down' not in self.args:
 
59
            if not self.args.no_tear_down:
54
60
                self.tear_down()