def test_psys_dryrun(capsys): """ Test routine psys with dryrun True and quiet False. """ pytest.debug_func() v = optparse.Values({'dryrun': True, 'quiet': False}) expected = "would do 'ls -d nosuchfile'\n" fx.psys('ls -d nosuchfile', v) assert expected in "".join(capsys.readouterr())
def test_psys_quiet(tmpdir, capsys, data): """ Test routine psys with dryrun False and quiet True. """ pytest.debug_func() with U.Chdir(tmpdir.strpath): exp = "a.xyzzy\nb.xyzzy\nc.xyzzy\ntmpfile\n" v = optparse.Values({'dryrun': False, 'quiet': True}) fx.psys('ls', v) assert exp == "".join(capsys.readouterr())
def test_psys_neither(capsys): """ Test routine psys with dryrun False and quiet False. """ pytest.debug_func() root = U.findroot() v = optparse.Values({'dryrun': False, 'quiet': False}) expected = "ls -d %s/fx.py\n%s/fx.py\n" % (root, root) fx.psys('ls -d %s/fx.py' % root, v) assert expected in " ".join(capsys.readouterr())
def test_psys_both(self): """ Test routine psys with dryrun True and quiet True. """ with th.StdoutExcursion() as getval: v = optparse.Values({'dryrun': True, 'quiet': True}) fx.psys('ls -d fx.py', v) actual = getval() expected = "would do 'ls -d fx.py'\n" assert(expected == actual)
def test_psys_dryrun(self): """ Test routine psys with dryrun True and quiet False. """ with th.StdoutExcursion() as getval: v = optparse.Values({'dryrun': True, 'quiet': False}) fx.psys('ls -d nosuchfile', v) actual = getval() expected = "would do 'ls -d nosuchfile'\n" self.assertEq(expected, actual)
def test_psys_neither(self): """ Test routine psys with dryrun False and quiet False. """ root = U.findroot() with th.StdoutExcursion() as getval: v = optparse.Values({'dryrun': False, 'quiet': False}) fx.psys('ls -d %s/fx.py' % root, v) actual = getval() expected = "ls -d %s/fx.py\n%s/fx.py\n" % (root, root) self.assertEq(expected, actual)
def test_psys_quiet(self): """ Test routine psys with dryrun False and quiet True. """ with U.Chdir(self.testdir): with th.StdoutExcursion() as getval: v = optparse.Values({'dryrun': False, 'quiet': True}) fx.psys('ls', v) actual = getval() expected = "a.xyzzy\nb.xyzzy\nc.xyzzy\ntmpfile\n" self.assertEqual(expected, actual, "%s\n !=\n%s" % (U.lquote(expected), U.lquote(actual)))