def test_version(self, versionarg, capsys): with raises(SystemExit) as exc_info: main(['progname', versionarg]) out, err = capsys.readouterr() # Should print out version. assert out == '{0} {1}\n'.format(metadata.project, metadata.version) # Should exit with zero return code. assert exc_info.value.code == 0
def test_help(self, helparg, capsys): with raises(SystemExit) as exc_info: main(['progname', helparg]) out, err = capsys.readouterr() # Should have printed some sort of usage message. We don't # need to explicitly test the content of the message. assert 'usage' in out # Should have used the program name from the argument # vector. assert 'progname' in out # Should exit with zero return code. assert exc_info.value.code == 0
def test_clock(self): # Arrange self.mock_clock.return_value = 'time' # Act result = main.main() # Assert self.assertEqual(result, 'time')
def run(args): """Run the package's main script. All arguments are passed to it.""" # The main script expects to get the called executable's name as # argv[0]. However, paver doesn't provide that in args. Even if it did (or # we dove into sys.argv), it wouldn't be useful because it would be paver's # executable. So we just pass the package name in as the executable name, # since it's close enough. This should never be seen by an end user # installing through Setuptools anyway. from server.main import main raise SystemExit(main([CODE_DIRECTORY] + args))
import sys from server.main import main print('Running server as a module.') main(sys.argv[1:])
import sys from server.main import main from .db import run_script as sql from .trade.player import run_script as play from .tinkoff import main as api import logging logger = logging.getLogger(__name__) if len(sys.argv) > 1: prog = sys.argv[1] if prog == 'api': api() elif prog == 'sql': sql() elif prog == 'play': play() else: print('NO Action! main start') main() else: main()
from server import main main.main()