Merge lp:~dobey/tarmac/fix-whoami into lp:tarmac

Proposed by dobey
Status: Merged
Approved by: Paul Hummer
Approved revision: 357
Merged at revision: 355
Proposed branch: lp:~dobey/tarmac/fix-whoami
Merge into: lp:tarmac
Diff against target: 159 lines (+24/-14)
4 files modified
tarmac/plugins/tests/test_bugresolver.py (+3/-2)
tarmac/plugins/tests/test_recipebuilder.py (+1/-0)
tarmac/tests/__init__.py (+7/-2)
tarmac/tests/test_branch.py (+13/-10)
To merge this branch: bzr merge lp:~dobey/tarmac/fix-whoami
Reviewer Review Type Date Requested Status
Paul Hummer Approve
Gavin Panella (community) Approve
Review via email: mp+35325@code.launchpad.net

Commit message

Use bzr's TestCaseInTempDir to avoid bzr whoami errors
Fix a couple more pep8 complaints

To post a comment you must log in.
lp:~dobey/tarmac/fix-whoami updated
355. By dobey

Fix pyflakes/pep8 issues

Revision history for this message
Gavin Panella (allenap) wrote :

This works (for me) on Lucid with bzr 2.2 :)

I hope you don't mind, but I had one comment:

+ TestCaseInTempDir.setUp(self)

TestCaseInTempDir.setUp() uses super(), so I think it would be better
to use it here too. There are several other places where the super
classes are explicitly called and they should probably change too.

review: Approve
lp:~dobey/tarmac/fix-whoami updated
356. By dobey

Switch to using super for the testcase inheritence
Switch to using bzrlib's TestCaseInTempDir for all test cases
Cache and restore the old tempfile.tempdir value

357. By dobey

Fix pyflakes/pep8 issues

Revision history for this message
Paul Hummer (rockstar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tarmac/plugins/tests/test_bugresolver.py'
--- tarmac/plugins/tests/test_bugresolver.py 2010-09-09 16:28:47 +0000
+++ tarmac/plugins/tests/test_bugresolver.py 2010-09-14 16:58:40 +0000
@@ -19,6 +19,7 @@
19from tarmac.tests import TarmacTestCase19from tarmac.tests import TarmacTestCase
20from tarmac.tests.mock import Thing20from tarmac.tests.mock import Thing
2121
22
22class BugResolverTests(TarmacTestCase):23class BugResolverTests(TarmacTestCase):
23 """Test the BugResolver."""24 """Test the BugResolver."""
2425
@@ -35,12 +36,12 @@
35 pass36 pass
3637
37 bugs = {38 bugs = {
38 '0' : Thing(39 '0': Thing(
39 bug_tasks=[Thing(target='Target', status='In Progress',40 bug_tasks=[Thing(target='Target', status='In Progress',
40 lp_save=lp_save),41 lp_save=lp_save),
41 Thing(target='Ubuntu', status='Incomplete',42 Thing(target='Ubuntu', status='Incomplete',
42 lp_save=lp_save)]),43 lp_save=lp_save)]),
43 '1' : Thing(44 '1': Thing(
44 bug_tasks=[Thing(target='Target', status='Confirmed',45 bug_tasks=[Thing(target='Target', status='Confirmed',
45 lp_save=lp_save)]),46 lp_save=lp_save)]),
46 }47 }
4748
=== modified file 'tarmac/plugins/tests/test_recipebuilder.py'
--- tarmac/plugins/tests/test_recipebuilder.py 2010-09-09 16:28:47 +0000
+++ tarmac/plugins/tests/test_recipebuilder.py 2010-09-14 16:58:40 +0000
@@ -19,6 +19,7 @@
19from tarmac.tests import TarmacTestCase19from tarmac.tests import TarmacTestCase
20from tarmac.tests.mock import Thing20from tarmac.tests.mock import Thing
2121
22
22class RecipeBuilderTests(TarmacTestCase):23class RecipeBuilderTests(TarmacTestCase):
23 """Test the Recipe Builder."""24 """Test the Recipe Builder."""
2425
2526
=== modified file 'tarmac/tests/__init__.py'
--- tarmac/tests/__init__.py 2010-08-13 18:56:40 +0000
+++ tarmac/tests/__init__.py 2010-09-14 16:58:40 +0000
@@ -18,12 +18,12 @@
18import os18import os
19import shutil19import shutil
20import tempfile20import tempfile
21import unittest
2221
22from bzrlib.tests import TestCaseInTempDir
23from tarmac.config import TarmacConfig23from tarmac.config import TarmacConfig
2424
2525
26class TarmacTestCase(unittest.TestCase):26class TarmacTestCase(TestCaseInTempDir):
27 '''A base TestCase for all Tarmac tests.'''27 '''A base TestCase for all Tarmac tests.'''
2828
29 CREDS_TEMPLATE = '''29 CREDS_TEMPLATE = '''
@@ -36,6 +36,9 @@
3636
37 def setUp(self):37 def setUp(self):
38 # Set up the environment.38 # Set up the environment.
39 super(TarmacTestCase, self).setUp()
40
41 self._oldtemp = tempfile.tempdir
39 tempfile.tempdir = os.getcwd()42 tempfile.tempdir = os.getcwd()
40 self.tempdir = tempfile.mkdtemp(dir=os.getcwd())43 self.tempdir = tempfile.mkdtemp(dir=os.getcwd())
41 os.environ['TARMAC_CONFIG_HOME'] = os.path.join(44 os.environ['TARMAC_CONFIG_HOME'] = os.path.join(
@@ -61,6 +64,8 @@
61 del os.environ[key]64 del os.environ[key]
62 except KeyError:65 except KeyError:
63 pass66 pass
67 tempfile.tempdir = self._oldtemp
68 super(TarmacTestCase, self).tearDown()
6469
65 def write_credentials_file(self):70 def write_credentials_file(self):
66 """Write out the temporary credentials file for testing."""71 """Write out the temporary credentials file for testing."""
6772
=== modified file 'tarmac/tests/test_branch.py'
--- tarmac/tests/test_branch.py 2010-09-02 15:18:07 +0000
+++ tarmac/tests/test_branch.py 2010-09-14 16:58:40 +0000
@@ -18,6 +18,7 @@
1818
19'''Tests for tarmac.branch'''19'''Tests for tarmac.branch'''
20import os20import os
21import shutil
2122
22from bzrlib.errors import PointlessMerge23from bzrlib.errors import PointlessMerge
2324
@@ -31,10 +32,7 @@
3132
32 def setUp(self):33 def setUp(self):
33 '''Set up the test environment.'''34 '''Set up the test environment.'''
34 TarmacTestCase.setUp(self)35 super(TestBranch, self).setUp()
35
36 self.bzrdir = os.path.join(os.getcwd(), "bzr")
37 os.environ['BZR_HOME'] = self.bzrdir
3836
39 self.branch1, self.branch2 = self.make_two_branches_to_merge()37 self.branch1, self.branch2 = self.make_two_branches_to_merge()
4038
@@ -42,12 +40,15 @@
42 """Tear down the tests."""40 """Tear down the tests."""
43 self.remove_branch_config(self.branch1.lp_branch.tree_dir)41 self.remove_branch_config(self.branch1.lp_branch.tree_dir)
44 self.remove_branch_config(self.branch2.lp_branch.tree_dir)42 self.remove_branch_config(self.branch2.lp_branch.tree_dir)
45 TarmacTestCase.tearDown(self)43 shutil.rmtree(self.branch1.lp_branch.tree_dir)
44 shutil.rmtree(self.branch2.lp_branch.tree_dir)
45
46 super(TestBranch, self).tearDown()
4647
47 def make_two_branches_to_merge(self):48 def make_two_branches_to_merge(self):
48 '''Make two branches, one with revisions to merge.'''49 '''Make two branches, one with revisions to merge.'''
49 branch1_dir = os.path.join(self.tempdir, 'branch1')50 branch1_dir = os.path.join(self.TEST_ROOT, 'branch1')
50 branch2_dir = os.path.join(self.tempdir, 'branch2')51 branch2_dir = os.path.join(self.TEST_ROOT, 'branch2')
51 self.add_branch_config(branch1_dir)52 self.add_branch_config(branch1_dir)
52 self.add_branch_config(branch2_dir)53 self.add_branch_config(branch2_dir)
5354
@@ -72,7 +73,7 @@
7273
73 def test_create(self):74 def test_create(self):
74 '''Test the creation of a TarmacBranch instance.'''75 '''Test the creation of a TarmacBranch instance.'''
75 tree_dir = os.path.join(self.tempdir, 'test_create')76 tree_dir = os.path.join(self.TEST_ROOT, 'test_create')
76 self.add_branch_config(tree_dir)77 self.add_branch_config(tree_dir)
7778
78 a_branch = branch.Branch.create(MockLPBranch(tree_dir), self.config)79 a_branch = branch.Branch.create(MockLPBranch(tree_dir), self.config)
@@ -89,7 +90,7 @@
8990
90 def test_merge_raises_exception_with_no_tree(self):91 def test_merge_raises_exception_with_no_tree(self):
91 '''A merge on a branch with no tree will raise an exception.'''92 '''A merge on a branch with no tree will raise an exception.'''
92 branch3_dir = os.path.join(self.tempdir, 'branch3')93 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')
93 self.add_branch_config(branch3_dir)94 self.add_branch_config(branch3_dir)
94 branch3 = branch.Branch.create(MockLPBranch(95 branch3 = branch.Branch.create(MockLPBranch(
95 branch3_dir, source_branch=self.branch1.lp_branch),96 branch3_dir, source_branch=self.branch1.lp_branch),
@@ -98,11 +99,12 @@
98 self.assertRaises(99 self.assertRaises(
99 AttributeError, branch3.merge, self.branch2)100 AttributeError, branch3.merge, self.branch2)
100 self.remove_branch_config(branch3_dir)101 self.remove_branch_config(branch3_dir)
102 shutil.rmtree(branch3_dir)
101103
102 def test_merge_no_changes(self):104 def test_merge_no_changes(self):
103 '''A merge on a branch with a tree will raise an exception if no105 '''A merge on a branch with a tree will raise an exception if no
104 changes are present.'''106 changes are present.'''
105 branch3_dir = os.path.join(self.tempdir, 'branch3')107 branch3_dir = os.path.join(self.TEST_ROOT, 'branch3')
106 self.add_branch_config(branch3_dir)108 self.add_branch_config(branch3_dir)
107 branch3 = branch.Branch.create(MockLPBranch(109 branch3 = branch.Branch.create(MockLPBranch(
108 branch3_dir, source_branch=self.branch1.lp_branch),110 branch3_dir, source_branch=self.branch1.lp_branch),
@@ -110,6 +112,7 @@
110112
111 self.assertRaises(PointlessMerge, self.branch1.merge, branch3)113 self.assertRaises(PointlessMerge, self.branch1.merge, branch3)
112 self.remove_branch_config(branch3_dir)114 self.remove_branch_config(branch3_dir)
115 shutil.rmtree(branch3_dir)
113116
114 def test_merge(self):117 def test_merge(self):
115 '''A merge on a branch with a tree of a branch with changes will merge.118 '''A merge on a branch with a tree of a branch with changes will merge.

Subscribers

People subscribed via source and target branches