예제 #1
0
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())
예제 #2
0
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())
예제 #3
0
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())
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
0
 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)
예제 #7
0
 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)))