Merge lp:~jml/pkgme/drop-matchers into lp:pkgme

Proposed by Jonathan Lange
Status: Merged
Approved by: James Westby
Approved revision: 131
Merged at revision: 129
Proposed branch: lp:~jml/pkgme/drop-matchers
Merge into: lp:pkgme
Diff against target: 195 lines (+28/-90)
5 files modified
NEWS.txt (+12/-1)
pkgme/testing.py (+0/-79)
pkgme/tests/test_script.py (+7/-5)
pkgme/tests/test_testing.py (+4/-2)
pkgme/tests/test_write.py (+5/-3)
To merge this branch: bzr merge lp:~jml/pkgme/drop-matchers
Reviewer Review Type Date Requested Status
pkgme committers Pending
Review via email: mp+118355@code.launchpad.net

Commit message

Remove matchers from pkgme. Now in testtools 0.9.13 or later.

Description of the change

pkgme had some great file-based matchers. These have been submitted to testtools,
landed and released. That release of testtools is now on precise and is thus
available on every OS we care to support.

As such, we can delete the matchers from pkgme and use the ones in testtools.

pkgme-devportal uses these matchers, so this should not land until
https://code.launchpad.net/~jml/pkgme-devportal/matchers-from-testtools/+merge/118352
lands.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS.txt'
2--- NEWS.txt 2012-08-03 15:47:04 +0000
3+++ NEWS.txt 2012-08-06 13:33:36 +0000
4@@ -1,11 +1,22 @@
5+-*- rst -*-
6 ==============
7 NEWS for pkgme
8 ==============
9
10+NEXT
11+====
12+
13+Changes
14+-------
15+
16+ * Many matchers were removed from ``pkgme.testing``. These matchers are now
17+ available in `testtools <http://pypi.python.org/pypi/testtools>`_ 0.9.13 or
18+ later.
19+
20 0.3 (2012-08-03)
21 ================
22
23- * New release, lots of new features.
24+ * New release, lots of new features.
25
26 0.2 (201X-XX-XX)
27 ================
28
29=== modified file 'pkgme/testing.py'
30--- pkgme/testing.py 2011-12-08 21:18:24 +0000
31+++ pkgme/testing.py 2012-08-06 13:33:36 +0000
32@@ -22,85 +22,6 @@
33 from pkgme.write import write_file
34
35
36-class PathMismatch(Mismatch):
37-
38- def __init__(self, path):
39- self.path = path
40-
41-
42-class PathDoesntExistMismatch(PathMismatch):
43-
44- def describe(self):
45- return "%s does not exist." % self.path
46-
47-
48-class PathIsNotDirectoryMismatch(PathMismatch):
49-
50- def describe(self):
51- return "%s is not a directory." % self.path
52-
53-
54-class PathExists(Matcher):
55-
56- def match(self, path):
57- if not os.path.exists(path):
58- return PathDoesntExistMismatch(path)
59-
60- def __str__(self):
61- return "Path exists"
62-
63-
64-class IsDirectory(Matcher):
65-
66- def match(self, path):
67- if not os.path.isdir(path):
68- return PathIsNotDirectoryMismatch(path)
69-
70-
71-class DirExists(Matcher):
72-
73- def match(self, path):
74- mismatch = PathExists().match(path)
75- if mismatch is not None:
76- return mismatch
77- return IsDirectory().match(path)
78-
79- def __str__(self):
80- return "Path exists and is a directory"
81-
82-
83-class DirContains(Matcher):
84-
85- def __init__(self, filenames):
86- self.filenames = filenames
87-
88- def match(self, path):
89- mismatch = PathExists().match(path)
90- if mismatch is not None:
91- return mismatch
92- mismatch = IsDirectory().match(path)
93- if mismatch is not None:
94- return mismatch
95- return Equals(sorted(self.filenames)).match(sorted(os.listdir(path)))
96-
97-
98-class FileContains(Matcher):
99-
100- def __init__(self, contents):
101- self.contents = contents
102-
103- def match(self, path):
104- mismatch = PathExists().match(path)
105- if mismatch is not None:
106- return mismatch
107- with open(path) as f:
108- actual_contents = f.read()
109- return Equals(self.contents).match(actual_contents)
110-
111- def __str__(self):
112- return "File at path exists and contains %s" % self.contents
113-
114-
115 class TempdirFixture(Fixture):
116
117 def setUp(self):
118
119=== modified file 'pkgme/tests/test_script.py'
120--- pkgme/tests/test_script.py 2012-07-20 19:24:04 +0000
121+++ pkgme/tests/test_script.py 2012-08-06 13:33:36 +0000
122@@ -8,7 +8,11 @@
123 MonkeyPatch,
124 )
125 from testtools import TestCase
126-from testtools.matchers import Not
127+from testtools.matchers import (
128+ DirContains,
129+ DirExists,
130+ Not,
131+ )
132
133 from pkgme.backend import (
134 BackendSelector,
135@@ -20,8 +24,6 @@
136 )
137 from pkgme.project_info import DictInfo
138 from pkgme.testing import (
139- DirContains,
140- DirExists,
141 TempdirFixture,
142 )
143
144@@ -106,8 +108,8 @@
145 def test_nosign(self):
146 tempdir = self.useFixture(TempdirFixture())
147 self.create_marker_file(tempdir, prefix='foo')
148- output = self.run_script(tempdir.abspath('foo'), ['--nosign'])
149- changes_file = os.path.join(tempdir.path,
150+ self.run_script(tempdir.abspath('foo'), ['--nosign'])
151+ changes_file = os.path.join(tempdir.path,
152 "foo_0.0.0_source.changes")
153 signature = open(changes_file)
154 sig_text = signature.readlines()
155
156=== modified file 'pkgme/tests/test_testing.py'
157--- pkgme/tests/test_testing.py 2011-07-15 09:22:47 +0000
158+++ pkgme/tests/test_testing.py 2012-08-06 13:33:36 +0000
159@@ -1,10 +1,12 @@
160 import os
161
162 from testtools import TestCase
163-
164-from pkgme.testing import (
165+from testtools.matchers import (
166 DirExists,
167 FileContains,
168+ )
169+
170+from pkgme.testing import (
171 TempdirFixture,
172 )
173
174
175=== modified file 'pkgme/tests/test_write.py'
176--- pkgme/tests/test_write.py 2012-06-19 13:54:19 +0000
177+++ pkgme/tests/test_write.py 2012-08-06 13:33:36 +0000
178@@ -2,12 +2,14 @@
179
180 from fixtures import TestWithFixtures
181 from testtools import TestCase
182-
183-from pkgme.package_files import PackageFile
184-from pkgme.testing import (
185+from testtools.matchers import (
186 DirExists,
187 FileContains,
188 PathExists,
189+ )
190+
191+from pkgme.package_files import PackageFile
192+from pkgme.testing import (
193 TempdirFixture,
194 )
195 from pkgme.write import (

Subscribers

People subscribed via source and target branches