Merge lp:~henninge/launchpad/bug-517080-pottery-split into lp:launchpad
- bug-517080-pottery-split
- Merge into devel
Proposed by
Henning Eggers
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Henning Eggers | ||||
Approved revision: | not available | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp:~henninge/launchpad/bug-517080-pottery-split | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
319 lines (+104/-47) 3 files modified
lib/lp/testing/__init__.py (+8/-8) lib/lp/translations/pottery/detect_intltool.py (+35/-0) lib/lp/translations/tests/test_pottery_detect_intltool.py (+61/-39) |
||||
To merge this branch: | bzr merge lp:~henninge/launchpad/bug-517080-pottery-split | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jeroen T. Vermeulen (community) | code | Approve | |
Review via email: mp+19325@code.launchpad.net |
Commit message
Provided check for possible intltool structure in a bzrlib.Tree.
Description of the change
To post a comment you must log in.
Revision history for this message
Henning Eggers (henninge) wrote : | # |
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote : | # |
Thanks for making the changes discussed in IRC. The new comments in the test are much clearer, and I think you've done a Good Thing™ in moving useTempDir up from TestCaseWithFactory into lp.testing.
The code is good, with nice use of "with." Two more tiny things, both in the docstring for is_intltool_
* Say "whether" in this case, not "if." But that does make the line a bit long. Personally I prefer to phrase these descriptions as questions: "Does this source tree look like it's set up for intltool?"
* Please make it state what "tree" is supposed to be.
review:
Approve
(code)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/lp/testing/__init__.py' | |||
2 | --- lib/lp/testing/__init__.py 2010-02-03 19:29:27 +0000 | |||
3 | +++ lib/lp/testing/__init__.py 2010-02-15 15:45:30 +0000 | |||
4 | @@ -368,6 +368,14 @@ | |||
5 | 368 | % (expected_count, len(statements), "\n".join(statements))) | 368 | % (expected_count, len(statements), "\n".join(statements))) |
6 | 369 | return ret | 369 | return ret |
7 | 370 | 370 | ||
8 | 371 | def useTempDir(self): | ||
9 | 372 | """Use a temporary directory for this test.""" | ||
10 | 373 | tempdir = tempfile.mkdtemp() | ||
11 | 374 | self.addCleanup(lambda: shutil.rmtree(tempdir)) | ||
12 | 375 | cwd = os.getcwd() | ||
13 | 376 | os.chdir(tempdir) | ||
14 | 377 | self.addCleanup(lambda: os.chdir(cwd)) | ||
15 | 378 | |||
16 | 371 | 379 | ||
17 | 372 | class TestCaseWithFactory(TestCase): | 380 | class TestCaseWithFactory(TestCase): |
18 | 373 | 381 | ||
19 | @@ -379,14 +387,6 @@ | |||
20 | 379 | self.factory = LaunchpadObjectFactory() | 387 | self.factory = LaunchpadObjectFactory() |
21 | 380 | self.real_bzr_server = False | 388 | self.real_bzr_server = False |
22 | 381 | 389 | ||
23 | 382 | def useTempDir(self): | ||
24 | 383 | """Use a temporary directory for this test.""" | ||
25 | 384 | tempdir = tempfile.mkdtemp() | ||
26 | 385 | self.addCleanup(lambda: shutil.rmtree(tempdir)) | ||
27 | 386 | cwd = os.getcwd() | ||
28 | 387 | os.chdir(tempdir) | ||
29 | 388 | self.addCleanup(lambda: os.chdir(cwd)) | ||
30 | 389 | |||
31 | 390 | def getUserBrowser(self, url=None): | 390 | def getUserBrowser(self, url=None): |
32 | 391 | """Return a Browser logged in as a fresh user, maybe opened at `url`. | 391 | """Return a Browser logged in as a fresh user, maybe opened at `url`. |
33 | 392 | """ | 392 | """ |
34 | 393 | 393 | ||
35 | === modified file 'lib/lp/translations/pottery/detect_intltool.py' | |||
36 | --- lib/lp/translations/pottery/detect_intltool.py 2009-12-23 18:10:37 +0000 | |||
37 | +++ lib/lp/translations/pottery/detect_intltool.py 2010-02-15 15:45:30 +0000 | |||
38 | @@ -6,6 +6,8 @@ | |||
39 | 6 | """Functions to detect if intltool can be used to generate a POT file for the | 6 | """Functions to detect if intltool can be used to generate a POT file for the |
40 | 7 | package in the current directory.""" | 7 | package in the current directory.""" |
41 | 8 | 8 | ||
42 | 9 | from __future__ import with_statement | ||
43 | 10 | |||
44 | 9 | __metaclass__ = type | 11 | __metaclass__ = type |
45 | 10 | __all__ = [ | 12 | __all__ = [ |
46 | 11 | 'check_potfiles_in', | 13 | 'check_potfiles_in', |
47 | @@ -20,6 +22,39 @@ | |||
48 | 20 | from subprocess import call | 22 | from subprocess import call |
49 | 21 | 23 | ||
50 | 22 | 24 | ||
51 | 25 | class ReadLockTree(object): | ||
52 | 26 | """Context manager to claim a read lock on a bzr tree.""" | ||
53 | 27 | |||
54 | 28 | def __init__(self, tree): | ||
55 | 29 | self.tree = tree | ||
56 | 30 | |||
57 | 31 | def __enter__(self): | ||
58 | 32 | self.tree.lock_read() | ||
59 | 33 | |||
60 | 34 | def __exit__(self, exc_type, exc_val, exc_tb): | ||
61 | 35 | self.tree.unlock() | ||
62 | 36 | return False | ||
63 | 37 | |||
64 | 38 | |||
65 | 39 | def is_intltool_structure(tree): | ||
66 | 40 | """Does this source tree look like it's set up for intltool? | ||
67 | 41 | |||
68 | 42 | Currently this just checks for the existence of POTFILES.in. | ||
69 | 43 | |||
70 | 44 | :param tree: A bzrlib.Tree object to search for the intltool structure. | ||
71 | 45 | :returns: True if signs of an intltool structure were found. | ||
72 | 46 | """ | ||
73 | 47 | with ReadLockTree(tree): | ||
74 | 48 | for thedir, files in tree.walkdirs(): | ||
75 | 49 | for afile in files: | ||
76 | 50 | file_path, file_name, file_type = afile[:3] | ||
77 | 51 | if file_type != 'file': | ||
78 | 52 | continue | ||
79 | 53 | if file_name == "POTFILES.in": | ||
80 | 54 | return True | ||
81 | 55 | return False | ||
82 | 56 | |||
83 | 57 | |||
84 | 23 | def find_potfiles_in(): | 58 | def find_potfiles_in(): |
85 | 24 | """Search the current directory and its subdirectories for POTFILES.in. | 59 | """Search the current directory and its subdirectories for POTFILES.in. |
86 | 25 | 60 | ||
87 | 26 | 61 | ||
88 | === modified file 'lib/lp/translations/tests/test_pottery_detect_intltool.py' | |||
89 | --- lib/lp/translations/tests/test_pottery_detect_intltool.py 2010-01-28 09:05:00 +0000 | |||
90 | +++ lib/lp/translations/tests/test_pottery_detect_intltool.py 2010-02-15 15:45:30 +0000 | |||
91 | @@ -10,59 +10,56 @@ | |||
92 | 10 | from StringIO import StringIO | 10 | from StringIO import StringIO |
93 | 11 | from textwrap import dedent | 11 | from textwrap import dedent |
94 | 12 | 12 | ||
95 | 13 | from bzrlib.bzrdir import BzrDir | ||
96 | 13 | from canonical.launchpad.scripts.tests import run_script | 14 | from canonical.launchpad.scripts.tests import run_script |
97 | 14 | from lp.translations.pottery.detect_intltool import ( | 15 | from lp.translations.pottery.detect_intltool import ( |
98 | 15 | ConfigFile, check_potfiles_in, find_intltool_dirs, find_potfiles_in, | 16 | ConfigFile, check_potfiles_in, find_intltool_dirs, find_potfiles_in, |
100 | 16 | get_translation_domain) | 17 | get_translation_domain, is_intltool_structure) |
101 | 17 | from lp.testing import TestCase | 18 | from lp.testing import TestCase |
102 | 18 | 19 | ||
123 | 19 | class TestDetectIntltool(TestCase): | 20 | |
124 | 20 | 21 | class SetupTestPackageMixin(object): | |
125 | 21 | def setUp(self): | 22 | |
126 | 22 | super(TestDetectIntltool, self).setUp() | 23 | def prepare_package(self, packagename): |
127 | 23 | # Determine test directory and create temporary working directory. | 24 | """Unpack the specified package in a temporary directory. |
128 | 24 | self.curdir = os.getcwd() | 25 | |
129 | 25 | self.testdir = os.path.join(self.curdir, os.path.dirname(__file__)) | 26 | Change into the package's directory. |
130 | 26 | self.workdir = tempfile.mkdtemp() | 27 | """ |
131 | 27 | os.chdir(self.workdir) | 28 | # First build the path for the package. |
132 | 28 | 29 | packagepath = os.path.join( | |
133 | 29 | def tearDown(self): | 30 | os.getcwd(), os.path.dirname(__file__), packagename + ".tar.bz2") |
134 | 30 | # Remove temporary directory. | 31 | # Then change into the temporary directory and unpack it. |
135 | 31 | os.chdir(self.curdir) | 32 | self.useTempDir() |
116 | 32 | shutil.rmtree(self.workdir) | ||
117 | 33 | super(TestDetectIntltool, self).tearDown() | ||
118 | 34 | |||
119 | 35 | def _prepare_package(self, packagename): | ||
120 | 36 | # Unpack the specified pacakge to run the test against it. | ||
121 | 37 | # Change to this directory. | ||
122 | 38 | packagepath = os.path.join(self.testdir, packagename+".tar.bz2") | ||
136 | 39 | tar = tarfile.open(packagepath, "r:bz2") | 33 | tar = tarfile.open(packagepath, "r:bz2") |
137 | 40 | tar.extractall() | 34 | tar.extractall() |
138 | 41 | tar.close() | 35 | tar.close() |
139 | 42 | os.chdir(packagename) | 36 | os.chdir(packagename) |
140 | 43 | 37 | ||
141 | 38 | |||
142 | 39 | class TestDetectIntltool(TestCase, SetupTestPackageMixin): | ||
143 | 40 | |||
144 | 44 | def test_detect_potfiles_in(self): | 41 | def test_detect_potfiles_in(self): |
145 | 45 | # Find POTFILES.in in a package with multiple dirs when only one has | 42 | # Find POTFILES.in in a package with multiple dirs when only one has |
146 | 46 | # POTFILES.in. | 43 | # POTFILES.in. |
148 | 47 | self._prepare_package("intltool_POTFILES_in_1") | 44 | self.prepare_package("intltool_POTFILES_in_1") |
149 | 48 | dirs = find_potfiles_in() | 45 | dirs = find_potfiles_in() |
150 | 49 | self.assertContentEqual(["./po-intltool"], dirs) | 46 | self.assertContentEqual(["./po-intltool"], dirs) |
151 | 50 | 47 | ||
152 | 51 | def test_detect_potfiles_in_module(self): | 48 | def test_detect_potfiles_in_module(self): |
153 | 52 | # Find POTFILES.in in a package with POTFILES.in at different levels. | 49 | # Find POTFILES.in in a package with POTFILES.in at different levels. |
155 | 53 | self._prepare_package("intltool_POTFILES_in_2") | 50 | self.prepare_package("intltool_POTFILES_in_2") |
156 | 54 | dirs = find_potfiles_in() | 51 | dirs = find_potfiles_in() |
157 | 55 | self.assertContentEqual(["./po", "./module1/po"], dirs) | 52 | self.assertContentEqual(["./po", "./module1/po"], dirs) |
158 | 56 | 53 | ||
159 | 57 | def test_check_potfiles_in_content_ok(self): | 54 | def test_check_potfiles_in_content_ok(self): |
160 | 58 | # Ideally all files listed in POTFILES.in exist in the source package. | 55 | # Ideally all files listed in POTFILES.in exist in the source package. |
162 | 59 | self._prepare_package("intltool_single_ok") | 56 | self.prepare_package("intltool_single_ok") |
163 | 60 | self.assertTrue(check_potfiles_in("./po")) | 57 | self.assertTrue(check_potfiles_in("./po")) |
164 | 61 | 58 | ||
165 | 62 | def test_check_potfiles_in_content_ok_file_added(self): | 59 | def test_check_potfiles_in_content_ok_file_added(self): |
166 | 63 | # If a file is not listed in POTFILES.in, the file is still good for | 60 | # If a file is not listed in POTFILES.in, the file is still good for |
167 | 64 | # our purposes. | 61 | # our purposes. |
169 | 65 | self._prepare_package("intltool_single_ok") | 62 | self.prepare_package("intltool_single_ok") |
170 | 66 | added_file = file("./src/sourcefile_new.c", "w") | 63 | added_file = file("./src/sourcefile_new.c", "w") |
171 | 67 | added_file.write("/* Test file. */") | 64 | added_file.write("/* Test file. */") |
172 | 68 | added_file.close() | 65 | added_file.close() |
173 | @@ -72,53 +69,53 @@ | |||
174 | 72 | # If a file is missing that is listed in POTFILES.in, the file | 69 | # If a file is missing that is listed in POTFILES.in, the file |
175 | 73 | # intltool structure is probably broken and cannot be used for | 70 | # intltool structure is probably broken and cannot be used for |
176 | 74 | # our purposes. | 71 | # our purposes. |
178 | 75 | self._prepare_package("intltool_single_ok") | 72 | self.prepare_package("intltool_single_ok") |
179 | 76 | os.remove("./src/sourcefile1.c") | 73 | os.remove("./src/sourcefile1.c") |
180 | 77 | self.assertFalse(check_potfiles_in("./po")) | 74 | self.assertFalse(check_potfiles_in("./po")) |
181 | 78 | 75 | ||
182 | 79 | def test_check_potfiles_in_wrong_directory(self): | 76 | def test_check_potfiles_in_wrong_directory(self): |
183 | 80 | # Passing in the wrong directory will cause the check to fail | 77 | # Passing in the wrong directory will cause the check to fail |
184 | 81 | # gracefully and return False. | 78 | # gracefully and return False. |
186 | 82 | self._prepare_package("intltool_single_ok") | 79 | self.prepare_package("intltool_single_ok") |
187 | 83 | self.assertFalse(check_potfiles_in("./foo")) | 80 | self.assertFalse(check_potfiles_in("./foo")) |
188 | 84 | 81 | ||
189 | 85 | def test_find_intltool_dirs(self): | 82 | def test_find_intltool_dirs(self): |
190 | 86 | # Complete run: find all directories with intltool structure. | 83 | # Complete run: find all directories with intltool structure. |
192 | 87 | self._prepare_package("intltool_full_ok") | 84 | self.prepare_package("intltool_full_ok") |
193 | 88 | self.assertEqual( | 85 | self.assertEqual( |
194 | 89 | ["./po-module1", "./po-module2"], find_intltool_dirs()) | 86 | ["./po-module1", "./po-module2"], find_intltool_dirs()) |
195 | 90 | 87 | ||
196 | 91 | def test_find_intltool_dirs_broken(self): | 88 | def test_find_intltool_dirs_broken(self): |
197 | 92 | # Complete run: part of the intltool structure is broken. | 89 | # Complete run: part of the intltool structure is broken. |
199 | 93 | self._prepare_package("intltool_full_ok") | 90 | self.prepare_package("intltool_full_ok") |
200 | 94 | os.remove("./src/module1/sourcefile1.c") | 91 | os.remove("./src/module1/sourcefile1.c") |
201 | 95 | self.assertEqual( | 92 | self.assertEqual( |
202 | 96 | ["./po-module2"], find_intltool_dirs()) | 93 | ["./po-module2"], find_intltool_dirs()) |
203 | 97 | 94 | ||
204 | 98 | def test_get_translation_domain_makevars(self): | 95 | def test_get_translation_domain_makevars(self): |
205 | 99 | # Find a translation domain in Makevars. | 96 | # Find a translation domain in Makevars. |
207 | 100 | self._prepare_package("intltool_domain_makevars") | 97 | self.prepare_package("intltool_domain_makevars") |
208 | 101 | self.assertEqual( | 98 | self.assertEqual( |
209 | 102 | "translationdomain", | 99 | "translationdomain", |
210 | 103 | get_translation_domain("po")) | 100 | get_translation_domain("po")) |
211 | 104 | 101 | ||
212 | 105 | def test_get_translation_domain_makefile_in_in(self): | 102 | def test_get_translation_domain_makefile_in_in(self): |
213 | 106 | # Find a translation domain in Makefile.in.in. | 103 | # Find a translation domain in Makefile.in.in. |
215 | 107 | self._prepare_package("intltool_domain_makefile_in_in") | 104 | self.prepare_package("intltool_domain_makefile_in_in") |
216 | 108 | self.assertEqual( | 105 | self.assertEqual( |
217 | 109 | "packagename-in-in", | 106 | "packagename-in-in", |
218 | 110 | get_translation_domain("po")) | 107 | get_translation_domain("po")) |
219 | 111 | 108 | ||
220 | 112 | def test_get_translation_domain_configure_ac(self): | 109 | def test_get_translation_domain_configure_ac(self): |
221 | 113 | # Find a translation domain in configure.ac. | 110 | # Find a translation domain in configure.ac. |
223 | 114 | self._prepare_package("intltool_domain_configure_ac") | 111 | self.prepare_package("intltool_domain_configure_ac") |
224 | 115 | self.assertEqual( | 112 | self.assertEqual( |
225 | 116 | "packagename-ac", | 113 | "packagename-ac", |
226 | 117 | get_translation_domain("po")) | 114 | get_translation_domain("po")) |
227 | 118 | 115 | ||
228 | 119 | def test_get_translation_domain_configure_in(self): | 116 | def test_get_translation_domain_configure_in(self): |
229 | 120 | # Find a translation domain in configure.in. | 117 | # Find a translation domain in configure.in. |
231 | 121 | self._prepare_package("intltool_domain_configure_in") | 118 | self.prepare_package("intltool_domain_configure_in") |
232 | 122 | self.assertEqual( | 119 | self.assertEqual( |
233 | 123 | "packagename-in", | 120 | "packagename-in", |
234 | 124 | get_translation_domain("po")) | 121 | get_translation_domain("po")) |
235 | @@ -126,7 +123,7 @@ | |||
236 | 126 | def test_get_translation_domain_makefile_in_in_substitute(self): | 123 | def test_get_translation_domain_makefile_in_in_substitute(self): |
237 | 127 | # Find a translation domain in Makefile.in.in with substitution from | 124 | # Find a translation domain in Makefile.in.in with substitution from |
238 | 128 | # configure.ac. | 125 | # configure.ac. |
240 | 129 | self._prepare_package("intltool_domain_makefile_in_in_substitute") | 126 | self.prepare_package("intltool_domain_makefile_in_in_substitute") |
241 | 130 | self.assertEqual( | 127 | self.assertEqual( |
242 | 131 | "domainname-ac-in-in", | 128 | "domainname-ac-in-in", |
243 | 132 | get_translation_domain("po")) | 129 | get_translation_domain("po")) |
244 | @@ -135,7 +132,7 @@ | |||
245 | 135 | # Find a translation domain in Makefile.in.in with substitution from | 132 | # Find a translation domain in Makefile.in.in with substitution from |
246 | 136 | # configure.ac from a variable with the same name as in | 133 | # configure.ac from a variable with the same name as in |
247 | 137 | # Makefile.in.in. | 134 | # Makefile.in.in. |
249 | 138 | self._prepare_package( | 135 | self.prepare_package( |
250 | 139 | "intltool_domain_makefile_in_in_substitute_same_name") | 136 | "intltool_domain_makefile_in_in_substitute_same_name") |
251 | 140 | self.assertEqual( | 137 | self.assertEqual( |
252 | 141 | "packagename-ac-in-in", | 138 | "packagename-ac-in-in", |
253 | @@ -144,7 +141,7 @@ | |||
254 | 144 | def test_get_translation_domain_makefile_in_in_substitute_same_file(self): | 141 | def test_get_translation_domain_makefile_in_in_substitute_same_file(self): |
255 | 145 | # Find a translation domain in Makefile.in.in with substitution from | 142 | # Find a translation domain in Makefile.in.in with substitution from |
256 | 146 | # the same file. | 143 | # the same file. |
258 | 147 | self._prepare_package( | 144 | self.prepare_package( |
259 | 148 | "intltool_domain_makefile_in_in_substitute_same_file") | 145 | "intltool_domain_makefile_in_in_substitute_same_file") |
260 | 149 | self.assertEqual( | 146 | self.assertEqual( |
261 | 150 | "domain-in-in-in-in", | 147 | "domain-in-in-in-in", |
262 | @@ -153,14 +150,14 @@ | |||
263 | 153 | def test_get_translation_domain_makefile_in_in_substitute_broken(self): | 150 | def test_get_translation_domain_makefile_in_in_substitute_broken(self): |
264 | 154 | # Find no translation domain in Makefile.in.in when the substitution | 151 | # Find no translation domain in Makefile.in.in when the substitution |
265 | 155 | # cannot be fulfilled. | 152 | # cannot be fulfilled. |
267 | 156 | self._prepare_package( | 153 | self.prepare_package( |
268 | 157 | "intltool_domain_makefile_in_in_substitute_broken") | 154 | "intltool_domain_makefile_in_in_substitute_broken") |
269 | 158 | self.assertIs(None, get_translation_domain("po")) | 155 | self.assertIs(None, get_translation_domain("po")) |
270 | 159 | 156 | ||
271 | 160 | def test_get_translation_domain_configure_in_substitute_version(self): | 157 | def test_get_translation_domain_configure_in_substitute_version(self): |
272 | 161 | # Find a translation domain in configure.in with Makefile-style | 158 | # Find a translation domain in configure.in with Makefile-style |
273 | 162 | # substitution from the same file. | 159 | # substitution from the same file. |
275 | 163 | self._prepare_package( | 160 | self.prepare_package( |
276 | 164 | "intltool_domain_configure_in_substitute_version") | 161 | "intltool_domain_configure_in_substitute_version") |
277 | 165 | self.assertEqual( | 162 | self.assertEqual( |
278 | 166 | "domainname-in42", | 163 | "domainname-in42", |
279 | @@ -168,7 +165,7 @@ | |||
280 | 168 | 165 | ||
281 | 169 | def test_pottery_check_intltool_script(self): | 166 | def test_pottery_check_intltool_script(self): |
282 | 170 | # Let the script run to see it works fine. | 167 | # Let the script run to see it works fine. |
284 | 171 | self._prepare_package("intltool_full_ok") | 168 | self.prepare_package("intltool_full_ok") |
285 | 172 | 169 | ||
286 | 173 | return_code, stdout, stderr = run_script( | 170 | return_code, stdout, stderr = run_script( |
287 | 174 | 'scripts/rosetta/pottery-check-intltool.py', []) | 171 | 'scripts/rosetta/pottery-check-intltool.py', []) |
288 | @@ -179,6 +176,31 @@ | |||
289 | 179 | """), stdout) | 176 | """), stdout) |
290 | 180 | 177 | ||
291 | 181 | 178 | ||
292 | 179 | class TestDetectIntltoolInBzrTree(TestCase, SetupTestPackageMixin): | ||
293 | 180 | |||
294 | 181 | def prepare_tree(self): | ||
295 | 182 | return BzrDir.create_standalone_workingtree(".") | ||
296 | 183 | |||
297 | 184 | def test_detect_intltool_structure(self): | ||
298 | 185 | # Detect a simple intltool structure. | ||
299 | 186 | self.prepare_package("intltool_POTFILES_in_1") | ||
300 | 187 | tree = self.prepare_tree() | ||
301 | 188 | self.assertTrue(is_intltool_structure(tree)) | ||
302 | 189 | |||
303 | 190 | def test_detect_no_intltool_structure(self): | ||
304 | 191 | # If no POTFILES.in exists, no intltool structure is assumed. | ||
305 | 192 | self.prepare_package("intltool_POTFILES_in_1") | ||
306 | 193 | os.remove("./po-intltool/POTFILES.in") | ||
307 | 194 | tree = self.prepare_tree() | ||
308 | 195 | self.assertFalse(is_intltool_structure(tree)) | ||
309 | 196 | |||
310 | 197 | def test_detect_intltool_structure_module(self): | ||
311 | 198 | # Detect an intltool structure in subdirectories. | ||
312 | 199 | self.prepare_package("intltool_POTFILES_in_2") | ||
313 | 200 | tree = self.prepare_tree() | ||
314 | 201 | self.assertTrue(is_intltool_structure(tree)) | ||
315 | 202 | |||
316 | 203 | |||
317 | 182 | class TestConfigFile(TestCase): | 204 | class TestConfigFile(TestCase): |
318 | 183 | 205 | ||
319 | 184 | def setUp(self): | 206 | def setUp(self): |
= Bug 517080 =
Although the bug talks about "splitting up", this branch really provides an extra function that simply checks for "POTFILES.in" existing in the tree. There was no code that could be re-used because the existing code works on the filesystem while this new function works directly on a bzrlib.Tree object.
== Implementation details ==
The code is straight forward - walk the tree and report success if a "POTFILES.in" is found.
This makes use of the new "with" statement with a context manager to acquire a lock on the tree. This seems to be a perfect use case for this new language feature and eventually the context manager should become part of bzrlib.Tree.
== Tests ==
The new test case uses the same packages as the tests that ran on the filesystem but uses BzrDir to create a working tree from the directories. The files in the trees don't actually get added and committed to the tree, simply because for the function to work this is not necessary.
To share some functionality between test cases, a mix-in class was created and some methods moved into it. This bloats the diff quite a bit because the method names lose a leading underscore.
bin/test -vvt pottery
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files: translations/ pottery/ detect_ intltool. py translations/ tests/test_ pottery_ detect_ intltool. py
lib/lp/
lib/lp/