@skip_if_on_windows
@pytest.mark.parametrize('cmd, fmt, exp', [('pwd', None, (lambda : (os.getcwd() + '\n'))), ('echo WORKING', None, 'WORKING\n'), ('ls -f', (lambda out: out.splitlines().sort()), os.listdir().sort())])
def test_single_command(cmd, fmt, exp):
 (out, err, rtn) = run_xonsh(cmd, stderr=sp.DEVNULL)
 if callable(fmt):
  out = fmt(out)
 if callable(exp):
  exp = exp()
 assert (out == exp)
 assert (rtn == 0)

@ skip_if_on_windows @ pytest . mark . parametrize ( 'cmd, fmt, exp' , [ ( 'pwd' , None , ( lambda : ( os . getcwd ( ) + '\n' ) ) ) , ( 'echo WORKING' , None , 'WORKING\n' ) , ( 'ls -f' , ( lambda out : out . splitlines ( ) . sort ( ) ) , os . listdir ( ) . sort ( ) ) ] ) def test_single_command ( cmd , fmt , exp ) : ( out , err , rtn ) = run_xonsh ( cmd , stderr = sp . DEVNULL ) if callable ( fmt ) : out = fmt ( out ) if callable ( exp ) : exp = exp ( ) assert ( out == exp ) assert ( rtn == 0 )
the fmt parameter is a function that formats the output of cmd .