def test_runner(tempfile): # test non-dry command call runner = Runner(dry=False) cmd = 'echo Testing real run > %s' % tempfile ret = runner.run(cmd) assert_equal(runner.commands, [], "Run of: %s resulted in non-empty buffer: %s" % (cmd, runner.commands.__str__())) assert_true(os.path.exists(tempfile), "Run of: %s resulted with non-existing file %s" % (cmd, tempfile)) # test non-dry python function call output = runner.call(os.path.join, 'foo', 'bar') assert_equal(os.path.join('foo', 'bar'), output, "Drycall of: os.path.join, 'foo', 'bar' returned %s" % output) assert_equal(runner.commands.__str__().find('os.path.join'), -1, "Drycall of: os.path.join, 'foo', 'bar' resulted in buffer: %s" % runner.commands.__str__())
def test_runner_dry(tempfile): runner = Runner(dry=True) # test dry command call cmd = 'echo Testing dry run > %s' % tempfile ret = runner.run(cmd) assert_equal(("DRY", "DRY"), ret, "Dry run of: %s resulted in output %s" % (cmd, ret)) assert_greater(runner.commands.__str__().find('echo Testing dry run'), -1, "Dry run of: %s resulted in buffer: %s" % (cmd, runner.commands.__str__())) assert_false(os.path.exists(tempfile)) # test dry python function call output = runner.call(os.path.join, 'foo', 'bar') assert_is(None, output, "Drycall of: os.path.join, 'foo', 'bar' returned %s" % output) assert_greater(runner.commands.__str__().find('join'), -1, "Drycall of: os.path.join, 'foo', 'bar' resulted in buffer: %s" % runner.commands.__str__())
def test_runner(tempfile): # test non-dry command call runner = Runner(dry=False) cmd = 'echo Testing real run > %s' % tempfile ret = runner.run(cmd) assert_equal( runner.commands, [], "Run of: %s resulted in non-empty buffer: %s" % (cmd, runner.commands.__str__())) assert_true( os.path.exists(tempfile), "Run of: %s resulted with non-existing file %s" % (cmd, tempfile)) # test non-dry python function call output = runner.call(os.path.join, 'foo', 'bar') assert_equal(os.path.join('foo', 'bar'), output, "Drycall of: os.path.join, 'foo', 'bar' returned %s" % output) assert_equal( runner.commands.__str__().find('os.path.join'), -1, "Drycall of: os.path.join, 'foo', 'bar' resulted in buffer: %s" % runner.commands.__str__())
def test_runner_dry(tempfile): runner = Runner(dry=True) # test dry command call cmd = 'echo Testing dry run > %s' % tempfile ret = runner.run(cmd) assert_equal(("DRY", "DRY"), ret, "Dry run of: %s resulted in output %s" % (cmd, ret)) assert_greater( runner.commands.__str__().find('echo Testing dry run'), -1, "Dry run of: %s resulted in buffer: %s" % (cmd, runner.commands.__str__())) assert_false(os.path.exists(tempfile)) # test dry python function call output = runner.call(os.path.join, 'foo', 'bar') assert_is(None, output, "Drycall of: os.path.join, 'foo', 'bar' returned %s" % output) assert_greater( runner.commands.__str__().find('join'), -1, "Drycall of: os.path.join, 'foo', 'bar' resulted in buffer: %s" % runner.commands.__str__())