<s> from __future__ import absolute_import <EOL> import argparse <EOL> import pytest <EOL> import os <EOL> import sys <EOL> is_python2 = sys . version_info [ <NUM_LIT:0> ] == <NUM_LIT:2> <EOL> import bokeh . command . subcommands . json as scjson <EOL> from bokeh . command . bootstrap import main <EOL> from . import ( <EOL> TmpDir , WorkingDir , with_directory_contents , basic_scatter_script <EOL> ) <EOL> def test_create ( ) : <EOL> import argparse <EOL> from bokeh . command . subcommand import Subcommand <EOL> obj = scjson . JSON ( parser = argparse . ArgumentParser ( ) ) <EOL> assert isinstance ( obj , Subcommand ) <EOL> def test_name ( ) : <EOL> assert scjson . JSON . name == "<STR_LIT>" <EOL> def test_help ( ) : <EOL> assert scjson . JSON . help == "<STR_LIT>" <EOL> def test_args ( ) : <EOL> assert scjson . JSON . args == ( <EOL> ( '<STR_LIT>' , dict ( <EOL> metavar = '<STR_LIT>' , <EOL> nargs = '<STR_LIT:+>' , <EOL> help = "<STR_LIT>" , <EOL> default = None <EOL> ) ) , <EOL> ( '<STR_LIT>' , dict ( <EOL> metavar = '<STR_LIT>' , <EOL> type = int , <EOL> help = "<STR_LIT>" , <EOL> default = None <EOL> ) ) , <EOL> ( ( '<STR_LIT>' , '<STR_LIT>' ) , dict ( <EOL> metavar = '<STR_LIT>' , <EOL> action = '<STR_LIT>' , <EOL> type = str , <EOL> help = "<STR_LIT>" <EOL> ) ) , <EOL> ( '<STR_LIT>' , dict ( <EOL> metavar = '<STR_LIT>' , <EOL> nargs = argparse . REMAINDER , <EOL> help = "<STR_LIT>" , <EOL> ) ) , <EOL> ) <EOL> def test_no_script ( capsys ) : <EOL> with ( TmpDir ( prefix = "<STR_LIT>" ) ) as dirname : <EOL> with WorkingDir ( dirname ) : <EOL> with pytest . raises ( SystemExit ) : <EOL> main ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> out , err = capsys . readouterr ( ) <EOL> if is_python2 : <EOL> too_few = "<STR_LIT>" <EOL> else : <EOL> too_few = "<STR_LIT>" <EOL> assert err == """<STR_LIT>""" % ( too_few ) <EOL> assert out == "<STR_LIT>" <EOL> def test_basic_script ( capsys ) : <EOL> def run ( dirname ) : <EOL> with WorkingDir ( dirname ) : <EOL> main ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> out , err = capsys . readouterr ( ) <EOL> assert err == "<STR_LIT>" <EOL> assert out == "<STR_LIT>" <EOL> assert set ( [ "<STR_LIT>" , "<STR_LIT>" ] ) == set ( os . listdir ( dirname ) ) <EOL> with_directory_contents ( { '<STR_LIT>' : basic_scatter_script } , <EOL> run ) <EOL> def test_basic_script_with_output_after ( capsys ) : <EOL> def run ( dirname ) : <EOL> with WorkingDir ( dirname ) : <EOL> main ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> out , err = capsys . readouterr ( ) <EOL> assert err == "<STR_LIT>" <EOL> assert out == "<STR_LIT>" <EOL> assert set ( [ "<STR_LIT>" , "<STR_LIT>" ] ) == set ( os . listdir ( dirname ) ) <EOL> with_directory_contents ( { '<STR_LIT>' : basic_scatter_script } , <EOL> run ) <EOL> def test_basic_script_with_output_before ( capsys ) : <EOL> def run ( dirname ) : <EOL> with WorkingDir ( dirname ) : <EOL> main ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> out , err = capsys . readouterr ( ) <EOL> assert err == "<STR_LIT>" <EOL> assert out == "<STR_LIT>" <EOL> assert set ( [ "<STR_LIT>" , "<STR_LIT>" ] ) == set ( os . listdir ( dirname ) ) <EOL> with_directory_contents ( { '<STR_LIT>' : basic_scatter_script } , <EOL> run ) </s>
