コード例 #1
0
def test_main():
    root_dir = Path(__file__).parent.parent
    result_csv = root_dir / 'result.csv'
    if result_csv.exists():
        result_csv.unlink()
    main(root_dir / 'cargo.csv', root_dir / 'trucks.csv')
    assert result_csv.exists()
コード例 #2
0
ファイル: test_main.py プロジェクト: Amylouise94/flask_app
 def test_version(self, versionarg, capsys):
     with raises(SystemExit) as exc_info:
         main(['progname', versionarg])
     out, err = capsys.readouterr()
     # Should print out version.
     assert err == '{0} {1}\n'.format(metadata.project, metadata.version)
     # Should exit with zero return code.
     assert exc_info.value.code == 0
コード例 #3
0
 def test_settings_are_initiated_when_app_running(self):
     mock = self.settings_patcher.start()
     with patch('sys.argv', ['_', r'./resources/specimen.tif']):
         main()
     self.settings_patcher.stop()
     mock.assert_called_once_with(
         debug_mode=False,
         output=None,
         path='./resources/specimen.tif',
     )
コード例 #4
0
ファイル: main_test.py プロジェクト: js17741166/eclipse2017
    def test_main_heals_correctly(self):
        main.uploader.heal = Mock(side_effect=AbortException)

        with self.assertRaises(AbortException):
            # Call under test
            main.main(sleep_time=0)

        main.uploader.scan.assert_called_with(constants.UPLOAD_DIR,
                                              file_ready=main.file_ready)
        main.uploader.upload.assert_called_with(self.files)
        exp_errors = main.uploader.upload(self.files)
        main.uploader.heal.assert_called_with(exp_errors)
コード例 #5
0
ファイル: test_main.py プロジェクト: Amylouise94/flask_app
 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
コード例 #6
0
ファイル: main_test.py プロジェクト: js17741166/eclipse2017
    def test_main_loops_forever(self):
        for num_safe_calls in (100, 10, 0, 200):
            side_effects = [None for _ in range(num_safe_calls)]
            side_effects.append(AbortException)

            main.uploader.heal = Mock(side_effect=side_effects)

            with self.assertRaises(AbortException):
                # Call under test
                main.main(sleep_time=0)

            self.assertEqual(len(main.uploader.heal.mock_calls),
                             num_safe_calls + 1)
コード例 #7
0
ファイル: run.py プロジェクト: lauraturner/CANDU-neutrinos
def calculate():
    if request.method == "POST":
        data = request.form.to_dict(flat=False)
        reactors = data['reactors[]']
        start = data['start'][0]
        end = data['end'][0]
        data = main.main(start, end, reactors)
        data = json.dumps(data)
        return data
コード例 #8
0
ファイル: pavement.py プロジェクト: Amylouise94/flask_app
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 app.main import main
    raise SystemExit(main([CODE_DIRECTORY] + args))
コード例 #9
0
ファイル: views.py プロジェクト: AStogov/timetableocr
def uploadImg(request):
    """
    图片上传
    :param request: 
    :return: 
    """
    context = {}
    if request.method == 'POST':
        new_img = IMG(img=request.FILES.get('img'),
                      name=request.FILES.get('img').name)
        new_img.save()
        context[
            "imgurl"] = "http://oken.club:81" + "/media/" + new_img.img.name
        context["data"] = main.main(context["imgurl"])
    return render(request, 'app/upload.html', context)
コード例 #10
0
def process(request):
    if request.method == 'POST':
        repoName = request.POST['repo']
        call_func = main.main(repoName)

        return HttpResponseRedirect('/result/')
コード例 #11
0
        file_path = "./tsx_1B.csv"
    return utils.read_stock_file(file_path)


def read_arguments(args):
    is_year_valid(args)
    is_period_valid(args)
    start_date, end_date = build_period_dates(args)
    stocks = get_stocks(args)
    return start_date, end_date, stocks


def output_results(best_stocks):
    print("The best stocks are: ", end='')
    print(", ".join(best_stocks))
    print()
    with open("output.txt", "w") as file:
        for stock in best_stocks:
            file.write(stock + ", ")


def set_thread_number(args):
    threads = int(args.thread)
    fetcher.thread_nb = threads


args = initialize_argparser()
set_thread_number(args)
start_date, end_date, stocks = read_arguments(args)
best_stocks = main(start_date, end_date, stocks)
output_results(best_stocks)
コード例 #12
0
ファイル: test_main.py プロジェクト: Cato-Old/epub_lib
 def test_calls_proper_method_on_book(self, mock_book) -> None:
     main()
     mock_book.return_value.dump.assert_called_once()
コード例 #13
0
ファイル: test_main.py プロジェクト: Cato-Old/epub_lib
 def test_initiates_settings_singleton(self, mock_book, mock_os) -> None:
     main()
     self.assertEqual(Settings().base_path, 'foo/bar/baz')
コード例 #14
0
"""
Copyright (C) 2018-2019 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import sys
from app.main import main

if __name__ == "__main__":
    sys.exit(main() or 0)
コード例 #15
0
ファイル: index.py プロジェクト: shopetan/codecheck-12863
#!/usr/bin/env python
import argparse
from app.main import main

parser = argparse.ArgumentParser(description='Write description here')
parser.add_argument('basic_arguments', nargs='*')

args = parser.parse_args()

main(args.basic_arguments, args)
コード例 #16
0
ファイル: test_main.py プロジェクト: Cato-Old/epub_lib
 def test_reads_passed_arguments(self, mock_book) -> None:
     main()
     mock_book.assert_called_with('path_name')
コード例 #17
0
ファイル: __main__.py プロジェクト: kumfc/pixel-battle-botnet
from asyncio import run
from app.main import main

if __name__ == '__main__':
    run(main())
コード例 #18
0
ファイル: test_main.py プロジェクト: rwdavis513/mass-sms
def test_main():

    main()
コード例 #19
0
ファイル: __main__.py プロジェクト: wh1210/data
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Entry point when run as a module.
See https://docs.python.org/3/library/__main__.html.
"""

from app import main

main.main()
コード例 #20
0
 def get_Pass(self,passw):
     password = main(passw)
     return {'num_it': password}
コード例 #21
0
def get_players(summoner_names):

    players = main(summoner_names)

    return jsonify(players)
コード例 #22
0
ファイル: main.py プロジェクト: MichaelMayorov/sympy-bot
from app.main import main

if __name__ == "__main__":
    main()
コード例 #23
0
 def ready(self):
     from app.main import main
     main()
コード例 #24
0
"""
This module is called when the package is executed as a module.
"""

import sys


if __name__ == "__main__":
    from app.main import main

    sys.exit(main())
コード例 #25
0
 def test_app_is_closed_when_no_required_args_provided(self):
     with self.assertRaises(SystemExit):
         main()
コード例 #26
0
def test_smoke():
    main.main()
コード例 #27
0
ファイル: index.py プロジェクト: iHalt10/codecheck-43892
import sys
from app.main import main

main(sys.argv[1:])
コード例 #28
0
 def test_app_is_running_when_required_args_provided(self):
     with patch('sys.argv', ['_', r'./resources/specimen.tif']):
         main()
     self.app_mock.run.assert_called_once()
コード例 #29
0
from app.main import main

if __name__ == '__main__':
    main()
コード例 #30
0
ファイル: app.py プロジェクト: sergioadsf/crawler-jogos
def execute():
    main.main()
    print('subindo')
    app.run()
    print('subiu')