Merge lp:~javier.collado/utah/use_isinstance into lp:utah

Proposed by Javier Collado
Status: Merged
Approved by: Javier Collado
Approved revision: 789
Merged at revision: 789
Proposed branch: lp:~javier.collado/utah/use_isinstance
Merge into: lp:utah
Diff against target: 55 lines (+5/-5)
5 files modified
examples/run_utah_tests.py (+1/-1)
utah/client/runner.py (+1/-1)
utah/client/tests/test_vcs_bzr.py (+1/-1)
utah/client/tests/test_vcs_dev.py (+1/-1)
utah/client/tests/test_vcs_git.py (+1/-1)
To merge this branch: bzr merge lp:~javier.collado/utah/use_isinstance
Reviewer Review Type Date Requested Status
Max Brustkern (community) Approve
Review via email: mp+139445@code.launchpad.net

Description of the change

This is a small refactoring to use `isinstance` instead of `type` since it's
considered a good practice.

To post a comment you must log in.
Revision history for this message
Max Brustkern (nuclearbob) wrote :

Looks reasonable to me. self.assertIsInstance(int(result), int) looks a little funny at first, but I guess if it fails to cast result to int, it'll raise an exception.

review: Approve
Revision history for this message
Javier Collado (javier.collado) wrote :

Yes, I guess that's only to make the test explicit. `int` raises a `ValueError`
exception in case of any problem.

I'm merging this now, but if Joe wants to update that to remove the assertion,
I can do that later.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/run_utah_tests.py'
2--- examples/run_utah_tests.py 2012-12-11 08:41:24 +0000
3+++ examples/run_utah_tests.py 2012-12-12 11:31:27 +0000
4@@ -130,7 +130,7 @@
5
6 if __name__ == '__main__':
7 try:
8- if type(config.jobtimeout) == int:
9+ if isinstance(config.jobtimeout, int):
10 try:
11 timeout(config.jobtimeout, run_utah_tests)
12 except UTAHTimeout:
13
14=== modified file 'utah/client/runner.py'
15--- utah/client/runner.py 2012-12-08 02:10:12 +0000
16+++ utah/client/runner.py 2012-12-12 11:31:27 +0000
17@@ -397,7 +397,7 @@
18
19 if 'testsuites' in data:
20 suites = data['testsuites']
21- elif type(data) == list:
22+ elif isinstance(data, list):
23 suites = data
24 else:
25 raise exceptions.BadMasterRunlist(str(data))
26
27=== modified file 'utah/client/tests/test_vcs_bzr.py'
28--- utah/client/tests/test_vcs_bzr.py 2012-12-03 14:02:18 +0000
29+++ utah/client/tests/test_vcs_bzr.py 2012-12-12 11:31:27 +0000
30@@ -95,4 +95,4 @@
31 result = bzr.get_revision(directory=path)
32
33 shutil.rmtree(path)
34- self.assertEqual(type(int(result)), int)
35+ self.assertIsInstance(int(result), int)
36
37=== modified file 'utah/client/tests/test_vcs_dev.py'
38--- utah/client/tests/test_vcs_dev.py 2012-12-03 14:02:18 +0000
39+++ utah/client/tests/test_vcs_dev.py 2012-12-12 11:31:27 +0000
40@@ -90,4 +90,4 @@
41 result = dev.get_revision(directory=path)
42
43 shutil.rmtree(path)
44- self.assertEqual(type(result), str)
45+ self.assertIsInstance(result, str)
46
47=== modified file 'utah/client/tests/test_vcs_git.py'
48--- utah/client/tests/test_vcs_git.py 2012-12-03 14:02:18 +0000
49+++ utah/client/tests/test_vcs_git.py 2012-12-12 11:31:27 +0000
50@@ -93,4 +93,4 @@
51 result = git.get_revision(directory=path)
52
53 shutil.rmtree(path)
54- self.assertEqual(type(result), str)
55+ self.assertIsInstance(result, str)

Subscribers

People subscribed via source and target branches