Mercurial > treepkg
comparison test/test_packager.py @ 113:312949e7628d
Add a smarter way to load the packager modules: Add the function
treepkg.packager.import_packager_module and use it to load the packager
modules. Also add corresponding tests.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Tue, 01 Apr 2008 12:30:39 +0000 |
parents | f7b9c7113c46 |
children | 093514306186 |
comparison
equal
deleted
inserted
replaced
112:cea98d4e4a6a | 113:312949e7628d |
---|---|
1 # Copyright (C) 2007 by Intevation GmbH | 1 # Copyright (C) 2007, 2008 by Intevation GmbH |
2 # Authors: | 2 # Authors: |
3 # Bernhard Herzog <bh@intevation.de> | 3 # Bernhard Herzog <bh@intevation.de> |
4 # | 4 # |
5 # This program is free software under the GPL (>=v2) | 5 # This program is free software under the GPL (>=v2) |
6 # Read the file COPYING coming with the software for details. | 6 # Read the file COPYING coming with the software for details. |
12 import unittest | 12 import unittest |
13 | 13 |
14 from treepkg.run import call | 14 from treepkg.run import call |
15 from treepkg.cmdexpand import cmdexpand | 15 from treepkg.cmdexpand import cmdexpand |
16 from treepkg.util import writefile | 16 from treepkg.util import writefile |
17 from treepkg.packager import PackagerGroup | 17 from treepkg.packager import PackagerGroup, import_packager_module |
18 import treepkg.subversion as subversion | 18 import treepkg.subversion as subversion |
19 import treepkg | 19 import treepkg |
20 | 20 |
21 from filesupport import FileTestMixin | 21 from filesupport import FileTestMixin |
22 | 22 |
342 srcdir = os.path.join(self.trackdir, "pkg", "704195-1", "binary") | 342 srcdir = os.path.join(self.trackdir, "pkg", "704195-1", "binary") |
343 self.assertEquals(revpkg.list_binary_files(), | 343 self.assertEquals(revpkg.list_binary_files(), |
344 [os.path.join(srcdir, filename) | 344 [os.path.join(srcdir, filename) |
345 for filename in ["test_1.0-1_i386.changes", | 345 for filename in ["test_1.0-1_i386.changes", |
346 "test_1.0-1_i386.deb"]]) | 346 "test_1.0-1_i386.deb"]]) |
347 | |
348 | |
349 class TestImportPackagerModule(unittest.TestCase, FileTestMixin): | |
350 | |
351 files = [("treepkg_importtest", | |
352 [("__init__.py", ""), | |
353 ("withtrack.py", "\n".join(["class PackageTrack:", | |
354 " pass", | |
355 ""])), | |
356 ("notrack.py", "\n".join(["class SourcePackager:", | |
357 " pass", | |
358 ""]))])] | |
359 | |
360 def setUp(self): | |
361 self.directory = self.create_temp_dir(self.id()) | |
362 self.create_files(self.directory, self.files) | |
363 self.old_path = sys.path | |
364 sys.path = [self.directory] + sys.path | |
365 | |
366 def tearDown(self): | |
367 sys.path = self.old_path | |
368 | |
369 def test_import_with_track(self): | |
370 module = import_packager_module("treepkg_importtest.withtrack") | |
371 self.failUnless(hasattr(module, "PackageTrack")) | |
372 | |
373 def test_import_without_track(self): | |
374 module = import_packager_module("treepkg_importtest.notrack") | |
375 self.failUnless(hasattr(module, "PackageTrack")) |