Beispiel #1
0
    def test_grab_stderr(self, tmpdir):
        tmp = tmpdir.join("test.out")
        spawn = Spawn(stderr=tmp.open('w'), stdout=None)
        spawn.run('perl -e "print STDERR 123456"', shell=True)

        assert tmp.read() == '123456'
        assert spawn.exitstatus == 0
Beispiel #2
0
    def test_grab_stderr(self, tmpdir):
        tmp = tmpdir.join("test.out")
        spawn = Spawn(stderr=tmp.open('w'), stdout=None)
        spawn.run('perl -e "print STDERR 123456"', shell=True)

        assert tmp.read() == '123456'
        assert spawn.exitstatus == 0
Beispiel #3
0
 def test_grab_stderr(self):
     f = open(outfile, 'w')
     spawn = Spawn(stderr=f, stdout=None)
     spawn.run('perl -e "print STDERR 123456"', shell=True)
     f.close()
     f = open(outfile)
     self.assertEqual(f.read(), '123456')
     self.assertEqual(spawn.exitstatus, 0)
     os.unlink(outfile)
Beispiel #4
0
 def test_shell_error(self):
     # With shell=True you don't get an OSError
     spawn = Spawn(shell=True, stdout=None)
     spawn.run('sadfasdfasdf')
     assert spawn.exitstatus != 0
     assert spawn.exitstatus is not None
Beispiel #5
0
 def test_multi_stdout(self):
     spawn = Spawn(stdout=[self.f, self.g])
     spawn.run('perl -e "print 123456"', shell=True)
     assert self.f.getvalue() == '123456'
     assert self.g.getvalue() == '123456'
     assert spawn.exitstatus == 0
Beispiel #6
0
 def test_timeout_error(self):
     spawn = Spawn(shell=True, timeout=1, stdout=None)
     with pytest.raises(RunTimeoutError):
         spawn.run('sleep 5')
     assert spawn.exitstatus == None
Beispiel #7
0
 def test_os_error(self):
     spawn = Spawn(stdout=None)
     with pytest.raises(OSError):
         spawn.run('bad command')
     assert spawn.exitstatus == None
Beispiel #8
0
 def test_ok(self):
     spawn = Spawn(stdout=self.f)
     spawn.run(['echo', 'hello world'])
     assert spawn.exitstatus == 0
     assert spawn.outlines == ['hello world\n']
     assert self.f.getvalue() == 'hello world\n'
Beispiel #9
0
 def test_shell_error(self):
     # With shell=True you don't get an OSError
     spawn = Spawn(shell=True, stdout=None)
     spawn.run('sadfasdfasdf')
     self.assertNotEqual(spawn.exitstatus, 0)
     self.assertNotEqual(spawn.exitstatus, None)
Beispiel #10
0
 def test_multi_stdout(self):
     spawn = Spawn(stdout=[self.f, self.g])
     spawn.run('perl -e "print 123456"', shell=True)
     self.assertEqual(self.f.getvalue(), '123456')
     self.assertEqual(self.g.getvalue(), '123456')
     self.assertEqual(spawn.exitstatus, 0)
Beispiel #11
0
 def test_ok(self):
     spawn = Spawn(stdout=self.f)
     spawn.run(['echo', 'hello world'])
     self.assertEqual(spawn.exitstatus, 0)
     self.assertEqual(spawn.outlines, ['hello world\n'])
     self.assertEqual(self.f.getvalue(), 'hello world\n')
Beispiel #12
0
 def test_shell_error(self):
     # With shell=True you don't get an OSError
     spawn = Spawn(shell=True, stdout=None)
     spawn.run('sadfasdfasdf')
     assert spawn.exitstatus != 0
     assert spawn.exitstatus is not None
Beispiel #13
0
 def test_multi_stdout(self):
     spawn = Spawn(stdout=[self.f, self.g])
     spawn.run('perl -e "print 123456"', shell=True)
     assert self.f.getvalue() == '123456'
     assert self.g.getvalue() == '123456'
     assert spawn.exitstatus == 0
Beispiel #14
0
 def test_timeout_error(self):
     spawn = Spawn(shell=True, timeout=1, stdout=None)
     with pytest.raises(RunTimeoutError):
         spawn.run('sleep 5')
     assert spawn.exitstatus is None
Beispiel #15
0
 def test_os_error(self):
     spawn = Spawn(stdout=None)
     with pytest.raises(OSError):
         spawn.run('bad command')
     assert spawn.exitstatus is None
Beispiel #16
0
 def test_ok(self):
     spawn = Spawn(stdout=self.f)
     spawn.run(['echo', 'hello world'])
     assert spawn.exitstatus == 0
     assert spawn.outlines == ['hello world\n']
     assert self.f.getvalue() == 'hello world\n'