From 79b8d472cf7e478558bd1c94a35bcd2ff408a3a1 Mon Sep 17 00:00:00 2001 From: Kieron Briggs Date: Fri, 30 Aug 2013 10:46:46 +1000 Subject: [PATCH] Make test_jenkins_artifacts more forgiving On some systems, 127.0.0.1 reverse-resolves to an actual hostname, and not to 'localhost'. Hence, match the output by the IP address instead. --- jenkinsapi_tests/systests/test_jenkins_artifacts.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jenkinsapi_tests/systests/test_jenkins_artifacts.py b/jenkinsapi_tests/systests/test_jenkins_artifacts.py index 42abdcb..1cf155e 100644 --- a/jenkinsapi_tests/systests/test_jenkins_artifacts.py +++ b/jenkinsapi_tests/systests/test_jenkins_artifacts.py @@ -2,6 +2,7 @@ System tests for `jenkinsapi.jenkins` module. ''' import os +import re import time import gzip import shutil @@ -38,7 +39,7 @@ class TestPingerJob(BaseSystemTest): text_artifact.save_to_dir(tempDir) readBackText = open(os.path.join( tempDir, text_artifact.filename), 'rb').read().strip() - self.assertTrue(readBackText.startswith('PING localhost')) + self.assertTrue(re.match(r'^PING \S+ \(127.0.0.1\)', readBackText)) self.assertTrue(readBackText.endswith('ms')) # Verify that we can hande binary artifacts @@ -47,7 +48,7 @@ class TestPingerJob(BaseSystemTest): tempDir, binary_artifact.filename, ), 'rb' ).read().strip() - self.assertTrue(readBackText.startswith('PING localhost')) + self.assertTrue(re.match(r'^PING \S+ \(127.0.0.1\)', readBackText)) self.assertTrue(readBackText.endswith('ms')) finally: shutil.rmtree(tempDir) -- 2.34.1