Fix tags test to work with cross repo flags

bzr-revno: 2401
This commit is contained in:
Raoul Snyman 2014-07-13 21:56:02 +01:00 committed by Tim Bentley
commit a670724ebe
1 changed files with 8 additions and 3 deletions

View File

@ -30,7 +30,7 @@
Package to test for proper bzr tags. Package to test for proper bzr tags.
""" """
import os import os
import re
from unittest import TestCase from unittest import TestCase
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
@ -52,6 +52,10 @@ TAGS = [
['2.0', '2118'], ['2.0', '2118'],
['2.1.0', '2119'] ['2.1.0', '2119']
] ]
# Depending on the repository, we sometimes have the 2.0.x tags in the repo too. They come up with a revision number of
# "?", which I suspect is due to the fact that we're using shared repositories. This regular expression matches all
# 2.0.x tags.
TAG_SEARCH = re.compile('2\.0\.\d')
class TestBzrTags(TestCase): class TestBzrTags(TestCase):
@ -65,8 +69,9 @@ class TestBzrTags(TestCase):
# WHEN getting the branches tags # WHEN getting the branches tags
bzr = Popen(('bzr', 'tags', '--directory=' + path), stdout=PIPE) bzr = Popen(('bzr', 'tags', '--directory=' + path), stdout=PIPE)
stdout = bzr.communicate()[0] std_out = bzr.communicate()[0]
tags = [line.decode('utf-8').split() for line in stdout.splitlines()] tags = [line.decode('utf-8').split() for line in std_out.splitlines()]
tags = [t_r for t_r in tags if t_r[1] != '?' or not (t_r[1] == '?' and TAG_SEARCH.search(t_r[0]))]
# THEN the tags should match the accepted tags # THEN the tags should match the accepted tags
self.assertEqual(TAGS, tags, 'List of tags should match') self.assertEqual(TAGS, tags, 'List of tags should match')