mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-04-20 19:38:39 +00:00
Strip irrelevant lines from test output
It may happen that aptly retries to download data during tests (maybe because of a network issue), but our fixtures doesn't account for it. So, we strip those irrelevant lines before comparison.
This commit is contained in:
@@ -8,6 +8,7 @@ import json
|
|||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
import posixpath
|
import posixpath
|
||||||
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
import string
|
import string
|
||||||
@@ -279,6 +280,15 @@ class BaseTest(object):
|
|||||||
def get_gold(self, gold_name="gold"):
|
def get_gold(self, gold_name="gold"):
|
||||||
return self.gold_processor(open(self.get_gold_filename(gold_name), "r").read())
|
return self.gold_processor(open(self.get_gold_filename(gold_name), "r").read())
|
||||||
|
|
||||||
|
def strip_retry_lines(self, s):
|
||||||
|
for prefix in (
|
||||||
|
'Following redirect',
|
||||||
|
'Error downloading',
|
||||||
|
'Retrying',
|
||||||
|
):
|
||||||
|
s = re.sub(r'{}.*\n'.format(prefix), '', s)
|
||||||
|
return s
|
||||||
|
|
||||||
def check_output(self):
|
def check_output(self):
|
||||||
try:
|
try:
|
||||||
self.verify_match(self.get_gold(), self.output,
|
self.verify_match(self.get_gold(), self.output,
|
||||||
@@ -382,6 +392,10 @@ class BaseTest(object):
|
|||||||
a = match_prepare(a)
|
a = match_prepare(a)
|
||||||
b = match_prepare(b)
|
b = match_prepare(b)
|
||||||
|
|
||||||
|
# Make sure there is something to compare after `match_prepare`
|
||||||
|
if not a or not b:
|
||||||
|
raise Exception("content empty")
|
||||||
|
|
||||||
if a != b:
|
if a != b:
|
||||||
diff = "".join(difflib.unified_diff(
|
diff = "".join(difflib.unified_diff(
|
||||||
[l + "\n" for l in a.split("\n")], [l + "\n" for l in b.split("\n")]))
|
[l + "\n" for l in a.split("\n")], [l + "\n" for l in b.split("\n")]))
|
||||||
|
|||||||
@@ -362,6 +362,9 @@ class CreateMirror27Test(BaseTest):
|
|||||||
"""
|
"""
|
||||||
runCmd = "aptly mirror create --ignore-signatures mirror27 http://linux.dell.com/repo/community/ubuntu wheezy openmanage/740"
|
runCmd = "aptly mirror create --ignore-signatures mirror27 http://linux.dell.com/repo/community/ubuntu wheezy openmanage/740"
|
||||||
|
|
||||||
|
def outputMatchPrepare(self, s):
|
||||||
|
return self.strip_retry_lines(s)
|
||||||
|
|
||||||
def check(self):
|
def check(self):
|
||||||
self.check_output()
|
self.check_output()
|
||||||
self.check_cmd_output("aptly mirror show mirror27", "mirror_show")
|
self.check_cmd_output("aptly mirror show mirror27", "mirror_show")
|
||||||
|
|||||||
Reference in New Issue
Block a user