~sil2100/ubuntu-system-image/server-different_devices

« back to all changes in this revision

Viewing changes to lib/systemimage/tests/test_generators.py

  • Committer: Steve Langasek
  • Date: 2015-09-29 21:11:04 UTC
  • mfrom: (273.1.3 pep8fixes)
  • Revision ID: steve.langasek@canonical.com-20150929211104-u6n95mfqdg2a9468
MergeĀ lp:~barry/ubuntu-system-image/test-fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
from io import BytesIO, StringIO
34
34
from systemimage import config, generators, gpg, tools, tree
35
35
from systemimage.testing.helpers import HAS_TEST_KEYS, MISSING_KEYS_WARNING
 
36
from systemimage.tools import xz_uncompress
36
37
 
37
38
 
38
39
class GeneratorsTests(unittest.TestCase):
508
509
                os.path.join(self.config.publish_path, "pool",
509
510
                             "ubuntu-HASH.tar.xz"))
510
511
 
511
 
            # Check that for touch and pd the android hacks are executed
512
 
            target_obj = tarfile.open(
513
 
                os.path.join(self.config.publish_path, "pool",
514
 
                             "ubuntu-HASH.tar.xz"), "r:xz")
515
 
            if android_hacks:
516
 
                self.assertIn("system/android", target_obj.getnames())
517
 
            target_obj.close()
 
512
            # Check that for touch and pd the android hacks are executed.
 
513
            # Python 2.7 does not support tar.xz, so do it another way.
 
514
            xz_path = os.path.join(
 
515
                self.config.publish_path, "pool",
 
516
                "ubuntu-HASH.tar.xz")
 
517
            unxz_path = os.path.join(self.temp_directory, "temp-unpack.tar")
 
518
            try:
 
519
                xz_uncompress(xz_path, unxz_path)
 
520
                target_obj = tarfile.open(unxz_path, "r")
 
521
                if android_hacks:
 
522
                    self.assertIn("system/android", target_obj.getnames())
 
523
            finally:
 
524
                target_obj.close()
 
525
                os.remove(unxz_path)
518
526
 
519
527
            for entry in ("ubuntu-HASH.tar.xz", "ubuntu-HASH.tar.xz.asc",
520
528
                          "ubuntu-HASH.json", "ubuntu-HASH.json.asc"):