Commit b05377c5 authored by Jérome Perrin's avatar Jérome Perrin Committed by Rafael Monnerat

test: do not rely on external resources

Use buildout testing utility to start a webserver instead of downloading
from the internet.
This also fixes the test because the downloaded content changed.
parent 820ca23a
...@@ -226,17 +226,26 @@ class NonInformativeTests(unittest.TestCase): ...@@ -226,17 +226,26 @@ class NonInformativeTests(unittest.TestCase):
self.assertFalse(is_temp) self.assertFalse(is_temp)
self.assertEqual(file, url) self.assertEqual(file, url)
url = 'ftp://ftp.gnu.org/welcome.msg' tmpdir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tmpdir)
with open(os.path.join(tmpdir, 'hello.txt'), 'w') as f:
f.write('Hello\n')
# This file md5sum is 09f7e02f1290be211da707a266f153b3
port = zc.buildout.testing.start_server(tmpdir)
url = 'http://localhost:%s/hello.txt' % port
file, is_temp = recipe.download_file(url) file, is_temp = recipe.download_file(url)
self.assertTrue(is_temp) self.assertTrue(is_temp)
self.assertTrue(os.path.exists(file)) self.assertTrue(os.path.exists(file))
url = 'ftp://ftp.gnu.org/welcome.msg#0de362e544463d298ebb2c5d00a84698' url = 'http://localhost:%s/hello.txt#09f7e02f1290be211da707a266f153b3' % port
file, is_temp = recipe.download_file(url) file, is_temp = recipe.download_file(url)
self.assertTrue(is_temp) self.assertTrue(is_temp)
self.assertTrue(os.path.exists(file)) self.assertTrue(os.path.exists(file))
url = 'ftp://ftp.gnu.org/welcome.msg#0205' url = 'http://localhost:%s/hello.txt#0205' % port
self.assertRaises(zc.buildout.download.ChecksumError, recipe.download_file, url) self.assertRaises(zc.buildout.download.ChecksumError, recipe.download_file, url)
def test_buildout_prefix(self): def test_buildout_prefix(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment