~nskaggs/help-app/functional-test-template

« back to all changes in this revision

Viewing changes to internals/tests/test_links.py

  • Committer: Daniel Holbach
  • Date: 2015-05-13 10:04:27 UTC
  • mto: This revision was merged to the branch mainline in revision 135.
  • Revision ID: daniel.holbach@canonical.com-20150513100427-0ut3t815bulrsot3
fix tests run during package build, by fixing override of build location (temporary dir to avoid changing live data)

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
)
14
14
 
15
15
 
 
16
def clean_tempdir(tempdir):
 
17
    if os.path.exists(tempdir):
 
18
        shutil.rmtree(tempdir)
 
19
 
 
20
 
16
21
class BuildRunner():
17
22
    def __init__(self, build):
18
23
        self.tempdir = tempfile.mkdtemp()
21
26
        self.html_files = []
22
27
        self.rc = None
23
28
        if self.build == 'app':
24
 
            self.env = {'OUTPUTDIR_APP': self.tempdir}
 
29
            self.env = {'APP_DIR': self.tempdir}
25
30
        if self.build == 'web':
26
31
            self.env = {'OUTPUTDIR_WEB': self.tempdir}
 
32
        self.pwd = use_top_level_dir()
27
33
        self.run_build()
28
34
        self.find_html_files()
29
35
 
30
36
    def run_build(self):
31
 
        pwd = use_top_level_dir()
32
37
        self.rc = subprocess.call(['make', '-es', self.build], env=self.env)
33
 
        os.chdir(pwd)
 
38
        os.chdir(self.pwd)
34
39
 
35
40
    def find_html_files(self):
36
41
        for dirpath, dirnames, filenames in os.walk(self.tempdir):
40
45
 
41
46
    def __del__(self):
42
47
        clean_tempdir(self.tempdir)
43
 
 
44
 
 
45
 
def clean_tempdir(tempdir):
46
 
    if os.path.exists(tempdir):
47
 
        shutil.rmtree(tempdir)
 
48
        os.chdir(self.pwd)
48
49
 
49
50
 
50
51
class MyHTMLParser(HTMLParser):