Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(264326)

Unified Diff: Lib/test/test_tempfile.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_telnetlib.py ('k') | Lib/test/test_time.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_tempfile.py Fri Feb 07 17:53:13 2014 +0100
+++ b/Lib/test/test_tempfile.py Fri Feb 07 23:40:05 2014 +0200
@@ -92,7 +92,7 @@
for key in dict:
if key[0] != '_' and key not in expected:
unexp.append(key)
- self.assertTrue(len(unexp) == 0,
+ self.assertEqual(len(unexp), 0,
"unexpected keys: %s" % unexp)
@@ -169,7 +169,7 @@
cand = tempfile._candidate_tempdir_list()
- self.assertFalse(len(cand) == 0)
+ self.assertNotEqual(len(cand), 0)
for c in cand:
self.assertIsInstance(c, str)
@@ -254,7 +254,7 @@
a = tempfile._get_candidate_names()
b = tempfile._get_candidate_names()
- self.assertTrue(a is b)
+ self.assertIs(a, b)
@contextlib.contextmanager
@@ -428,7 +428,7 @@
p = tempfile.gettempprefix()
self.assertIsInstance(p, str)
- self.assertTrue(len(p) > 0)
+ self.assertGreater(len(p), 0)
def test_usable_template(self):
# gettempprefix returns a usable prefix string
@@ -454,8 +454,9 @@
# gettempdir returns a directory which exists
dir = tempfile.gettempdir()
- self.assertTrue(os.path.isabs(dir) or dir == os.curdir,
- "%s is not an absolute path" % dir)
+ if dir != os.curdir:
+ self.assertTrue(os.path.isabs(dir),
+ "%s is not an absolute path" % dir)
self.assertTrue(os.path.isdir(dir),
"%s is not a directory" % dir)
@@ -474,7 +475,7 @@
a = tempfile.gettempdir()
b = tempfile.gettempdir()
- self.assertTrue(a is b)
+ self.assertIs(a, b)
def test_case_sensitive(self):
# gettempdir should not flatten its case
@@ -846,7 +847,7 @@
# A SpooledTemporaryFile should roll over to a real file on fileno()
f = self.do_create(max_size=30)
self.assertFalse(f._rolled)
- self.assertTrue(f.fileno() > 0)
+ self.assertGreater(f.fileno(), 0)
self.assertTrue(f._rolled)
def test_multiple_close_before_rollover(self):
« no previous file with comments | « Lib/test/test_telnetlib.py ('k') | Lib/test/test_time.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+