diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-15 14:03:11 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-15 14:03:11 +0200 |
commit | 82e56142109837114c9abd1ae66deab22f5a1094 (patch) | |
tree | 9938d8db8d69b91f52ff8e046e37549ecd0367ca /Lib/test | |
parent | f2089387c42582d18f9b8cf89ca1eba088bb4549 (diff) | |
parent | b6fbb7ededa76c40650568147a5499e15ab7af87 (diff) | |
download | cpython-82e56142109837114c9abd1ae66deab22f5a1094.tar.gz |
Use os.devnull instead of hardcoded '/dev/null'.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_asyncio/test_unix_events.py | 6 | ||||
-rw-r--r-- | Lib/test/test_bz2.py | 10 | ||||
-rw-r--r-- | Lib/test/test_cgi.py | 4 | ||||
-rw-r--r-- | Lib/test/test_subprocess.py | 4 |
4 files changed, 12 insertions, 12 deletions
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py index 41249ff024..dc0835c527 100644 --- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -295,7 +295,7 @@ class SelectorEventLoopUnixSocketTests(test_utils.TestCase): def test_create_unix_connection_path_sock(self): coro = self.loop.create_unix_connection( - lambda: None, '/dev/null', sock=object()) + lambda: None, os.devnull, sock=object()) with self.assertRaisesRegex(ValueError, 'path and sock can not be'): self.loop.run_until_complete(coro) @@ -308,14 +308,14 @@ class SelectorEventLoopUnixSocketTests(test_utils.TestCase): def test_create_unix_connection_nossl_serverhost(self): coro = self.loop.create_unix_connection( - lambda: None, '/dev/null', server_hostname='spam') + lambda: None, os.devnull, server_hostname='spam') with self.assertRaisesRegex(ValueError, 'server_hostname is only meaningful'): self.loop.run_until_complete(coro) def test_create_unix_connection_ssl_noserverhost(self): coro = self.loop.create_unix_connection( - lambda: None, '/dev/null', ssl=True) + lambda: None, os.devnull, ssl=True) with self.assertRaisesRegex( ValueError, 'you have to pass server_hostname when using ssl'): diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py index ce012d6aa3..1535e8e669 100644 --- a/Lib/test/test_bz2.py +++ b/Lib/test/test_bz2.py @@ -87,11 +87,11 @@ class BZ2FileTest(BaseTest): def testBadArgs(self): self.assertRaises(TypeError, BZ2File, 123.456) - self.assertRaises(ValueError, BZ2File, "/dev/null", "z") - self.assertRaises(ValueError, BZ2File, "/dev/null", "rx") - self.assertRaises(ValueError, BZ2File, "/dev/null", "rbt") - self.assertRaises(ValueError, BZ2File, "/dev/null", compresslevel=0) - self.assertRaises(ValueError, BZ2File, "/dev/null", compresslevel=10) + self.assertRaises(ValueError, BZ2File, os.devnull, "z") + self.assertRaises(ValueError, BZ2File, os.devnull, "rx") + self.assertRaises(ValueError, BZ2File, os.devnull, "rbt") + self.assertRaises(ValueError, BZ2File, os.devnull, compresslevel=0) + self.assertRaises(ValueError, BZ2File, os.devnull, compresslevel=10) def testRead(self): self.createTempFile() diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py index 89a6e84df9..715bd73279 100644 --- a/Lib/test/test_cgi.py +++ b/Lib/test/test_cgi.py @@ -186,9 +186,9 @@ class CgiTests(unittest.TestCase): cgi.initlog("%s", "Testing initlog 1") cgi.log("%s", "Testing log 2") self.assertEqual(cgi.logfp.getvalue(), "Testing initlog 1\nTesting log 2\n") - if os.path.exists("/dev/null"): + if os.path.exists(os.devnull): cgi.logfp = None - cgi.logfile = "/dev/null" + cgi.logfile = os.devnull cgi.initlog("%s", "Testing log 3") self.addCleanup(cgi.closelog) cgi.log("Testing log 4") diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 3d34859ed4..460876f410 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1922,7 +1922,7 @@ class POSIXProcessTestCase(BaseTestCase): open_fds = set(fds) # add a bunch more fds for _ in range(9): - fd = os.open("/dev/null", os.O_RDONLY) + fd = os.open(os.devnull, os.O_RDONLY) self.addCleanup(os.close, fd) open_fds.add(fd) @@ -1984,7 +1984,7 @@ class POSIXProcessTestCase(BaseTestCase): open_fds = set() # Add a bunch more fds to pass down. for _ in range(40): - fd = os.open("/dev/null", os.O_RDONLY) + fd = os.open(os.devnull, os.O_RDONLY) open_fds.add(fd) # Leave a two pairs of low ones available for use by the |