diff -r 811ccdee6f87 Lib/test/test_pipes.py --- a/Lib/test/test_pipes.py Wed May 04 09:44:44 2016 +0300 +++ b/Lib/test/test_pipes.py Wed May 04 22:05:38 2016 +0200 @@ -12,11 +12,16 @@ # tr a-z A-Z is not portable, so make the ranges explicit s_command = 'tr %s %s' % (string.ascii_lowercase, string.ascii_uppercase) +def _tr_exists(): + return any(os.path.isfile(p) for p in + (os.path.join(os.fsencode(dir), b'tr') for dir in os.get_exec_path())) + class SimplePipeTests(unittest.TestCase): def tearDown(self): for f in (TESTFN, TESTFN2): unlink(f) + @unittest.skipUnless(_tr_exists(), 'tr is not available') def testSimplePipe1(self): t = pipes.Template() t.append(s_command, pipes.STDIN_STDOUT) @@ -26,6 +31,7 @@ with open(TESTFN) as f: self.assertEqual(f.read(), 'HELLO WORLD #1') + @unittest.skipUnless(_tr_exists(), 'tr is not available') def testSimplePipe2(self): with open(TESTFN, 'w') as f: f.write('hello world #2') @@ -35,6 +41,7 @@ with open(TESTFN2) as f: self.assertEqual(f.read(), 'HELLO WORLD #2') + @unittest.skipUnless(_tr_exists(), 'tr is not available') def testSimplePipe3(self): with open(TESTFN, 'w') as f: f.write('hello world #2')