Merge lp:~cmiller/apt-zeroconf/fix-test-failures into lp:apt-zeroconf

Proposed by Chad Miller
Status: Merged
Merged at revision: 133
Proposed branch: lp:~cmiller/apt-zeroconf/fix-test-failures
Merge into: lp:apt-zeroconf
Diff against target: 123 lines (+23/-18)
4 files modified
aptzeroconf/http.py (+1/-1)
aptzeroconf/parse.py (+4/-2)
test/common.py (+3/-3)
test/test_general.py (+15/-12)
To merge this branch: bzr merge lp:~cmiller/apt-zeroconf/fix-test-failures
Reviewer Review Type Date Requested Status
Martin Owens (community) code Approve
Review via email: mp+76921@code.launchpad.net

Description of the change

Tests stopped working in recent Ubuntu or Python versions. Fixed a few style problems that automated tools complained about.

To post a comment you must log in.
Revision history for this message
Martin Owens (doctormo) wrote :

The patch/diff looks good and the test changes are awesome. Should be merged.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'aptzeroconf/http.py'
--- aptzeroconf/http.py 2009-09-12 02:04:35 +0000
+++ aptzeroconf/http.py 2011-09-26 00:07:25 +0000
@@ -145,7 +145,7 @@
145 @trap_socketerror145 @trap_socketerror
146 def do_GET(self):146 def do_GET(self):
147 self._do_GET()147 self._do_GET()
148 148
149 def _do_GET(self):149 def _do_GET(self):
150 """150 """
151 Respond to a GET request by proxy the url to preferably local content,151 Respond to a GET request by proxy the url to preferably local content,
152152
=== modified file 'aptzeroconf/parse.py'
--- aptzeroconf/parse.py 2009-08-09 02:39:51 +0000
+++ aptzeroconf/parse.py 2011-09-26 00:07:25 +0000
@@ -28,14 +28,16 @@
2828
29V2, V3 = 0.2, 0.329V2, V3 = 0.2, 0.3
30EPOCH_PATTERN = {30EPOCH_PATTERN = {
31 V2 : re.compile(r'\_\d+\%3a'),31 V2: re.compile(r'\_\d+\%3a'),
32 V3 : re.compile(r'\_\d+\:')32 V3: re.compile(r'\_\d+\:'),
33}33}
3434
35
35def normalize_whitespace(text):36def normalize_whitespace(text):
36 """Remove excessive whitespace in spaces."""37 """Remove excessive whitespace in spaces."""
37 return ' '.join(text.split())38 return ' '.join(text.split())
3839
40
39def _is_equal(pkg, find, ver):41def _is_equal(pkg, find, ver):
40 """Are the packages equal disregarding the epoch?"""42 """Are the packages equal disregarding the epoch?"""
41 return EPOCH_PATTERN[ver].sub('_', pkg) == find or pkg == find43 return EPOCH_PATTERN[ver].sub('_', pkg) == find or pkg == find
4244
=== modified file 'test/common.py'
--- test/common.py 2009-08-09 03:30:29 +0000
+++ test/common.py 2011-09-26 00:07:25 +0000
@@ -36,11 +36,11 @@
36ROOT = str(rootdir)36ROOT = str(rootdir)
3737
38DEBNAME = 'test_1.deb'38DEBNAME = 'test_1.deb'
39DEBEPOCHNAME = 'test_1%3a1.deb'39DEBEPOCHNAME = 'test_1%3A1.deb'
4040
41DEBPROXYURL = (41DEBPROXYURL = (
42 'archive.ubuntu.com/ubuntu/pool/main/h/hello/hello_2.2-3_i386.deb')42 'archive.ubuntu.com/ubuntu/pool/main/h/hello/hello_2.7-1_i386.deb')
43DEBFORWARDURL = 'ubuntu/pool/main/h/hello/hello_2.2-3_i386.deb'43DEBFORWARDURL = 'ubuntu/pool/main/h/hello/hello_2.7-1_i386.deb'
4444
45PORT = 4796 # random port that probably wont be in use45PORT = 4796 # random port that probably wont be in use
4646
4747
=== modified file 'test/test_general.py'
--- test/test_general.py 2009-08-09 03:57:29 +0000
+++ test/test_general.py 2011-09-26 00:07:25 +0000
@@ -72,16 +72,16 @@
72 touch(path.join(cachedir, DEBNAME), '*contents*')72 touch(path.join(cachedir, DEBNAME), '*contents*')
7373
74 with azc_server(str(tmpdir), cachedir, PORT,74 with azc_server(str(tmpdir), cachedir, PORT,
75 {('apt-cache', 'test'): 'http://example.com'}) as server:75 {('apt-cache', 'test'): 'http://notexist.example.com'}) as server:
76 data = urlopen('http://localhost:%i/http://example.com/%s' % (76 data = urlopen('http://localhost:%i/http://notexist.example.com/%s' % (
77 PORT, DEBNAME)).read()77 PORT, DEBNAME)).read()
78 # make sure the data is equal78 # make sure the data is equal
79 assert data == '*contents*'79 assert data == '*contents*'
8080
8181
82def test_download_one_epoch_deb(tmpdir):82def test_download_one_versionepoch_deb(tmpdir):
83 """83 """
84 Test downloading a deb with an epoch from the local cache.84 Test downloading a deb with a version epoch from the local cache.
85 """85 """
86 # cachedir is the directory to serve debs out of86 # cachedir is the directory to serve debs out of
87 cachedir = path.join(str(tmpdir), 'debs')87 cachedir = path.join(str(tmpdir), 'debs')
@@ -89,8 +89,8 @@
89 touch(path.join(cachedir, DEBEPOCHNAME), '*contents*')89 touch(path.join(cachedir, DEBEPOCHNAME), '*contents*')
9090
91 with azc_server(str(tmpdir), cachedir, PORT,91 with azc_server(str(tmpdir), cachedir, PORT,
92 {('apt-cache', 'test'): 'http://example.com'}) as server:92 {('apt-cache', 'test'): 'http://notexist.example.com'}) as server:
93 data = urlopen('http://localhost:%i/http://example.com/%s' % (93 data = urlopen('http://localhost:%i/http://notexist.example.com/%s' % (
94 PORT, DEBEPOCHNAME)).read()94 PORT, DEBEPOCHNAME)).read()
95 # make sure the data is equal95 # make sure the data is equal
96 assert data == '*contents*'96 assert data == '*contents*'
@@ -118,15 +118,17 @@
118 with azc_server(one, cacheone, PORT, one_config):118 with azc_server(one, cacheone, PORT, one_config):
119 with azc_server(two, cachetwo, PORT+1, two_config):119 with azc_server(two, cachetwo, PORT+1, two_config):
120 time.sleep(3.0) # wait for one to discover two120 time.sleep(3.0) # wait for one to discover two
121 data = urlopen('http://localhost:%i/http://example.com/%s' % (121 data = urlopen(
122 PORT, DEBNAME)).read()122 'http://localhost:%i/http://notexist.example.com/%s' % (
123 PORT, DEBNAME)).read()
123 # make sure the data is equal124 # make sure the data is equal
124 assert data == '*contents*'125 assert data == '*contents*'
125126
126127
127def test_download_epoch_local_server(tmpdir):128def test_download_versionepoch_local_server(tmpdir):
128 """129 """
129 Test fetching a file with an epoch from an AZC instance on the local network.130 Test fetching a file with an epoch from an AZC instance on the local
131 network.
130 """132 """
131 # cachedir is the directory to serve debs out of133 # cachedir is the directory to serve debs out of
132 one = path.join(str(tmpdir), 'one')134 one = path.join(str(tmpdir), 'one')
@@ -146,8 +148,9 @@
146 with azc_server(one, cacheone, PORT, one_config):148 with azc_server(one, cacheone, PORT, one_config):
147 with azc_server(two, cachetwo, PORT+1, two_config):149 with azc_server(two, cachetwo, PORT+1, two_config):
148 time.sleep(3.0) # wait for one to discover two150 time.sleep(3.0) # wait for one to discover two
149 data = urlopen('http://localhost:%i/http://example.com/%s' % (151 data = urlopen(
150 PORT, DEBNAME)).read()152 'http://localhost:%i/http://notexist.example.com/%s' % (
153 PORT, DEBNAME)).read()
151 # make sure the data is equal154 # make sure the data is equal
152 assert data == '*contents*'155 assert data == '*contents*'
153156

Subscribers

People subscribed via source and target branches