Exemplo n.º 1
0
def test_default_argument_values_incorrect(no_arguments, capsys):
    """No command-line arguments is incorrect"""
    with pytest.raises(SystemExit):
        arguments.parse(no_arguments)
    standard_out, standard_err = capsys.readouterr()
    assert standard_out is EMPTY_STRING
    assert ERROR in standard_err
    assert DIRECTORY in standard_err
Exemplo n.º 2
0
def test_module_argument_not_verifiable_syserror(chosen_arguments, capsys):
    """Check that not valid module arguments will not verify correctly"""
    with pytest.raises(SystemExit):
        arguments.parse(chosen_arguments)
    standard_out, standard_err = capsys.readouterr()
    assert standard_out is EMPTY_STRING
    assert ERROR in standard_err
    assert MODULE in standard_err
Exemplo n.º 3
0
def test_configuration_file_correct_types(correct_arguments, correct_types,
                                          tmpdir):
    """Checks that the configuration file was saved to the directory"""
    parsed_arguments = arguments.parse(correct_arguments)
    directory_prefix = str(tmpdir) + "/"
    configuration.save(directory_prefix + constants.CONFIGURATION,
                       vars(parsed_arguments))
    assert len(tmpdir.listdir()) == 1
    tada_configuration_dict = configuration.read(directory_prefix +
                                                 constants.CONFIGURATION)
    assert configuration.get_types(tada_configuration_dict) == correct_types
Exemplo n.º 4
0
def test_module_argument_not_verifiable(chosen_arguments):
    """Check that not valid directory arguments will not verify correctly"""
    parsed_arguments = arguments.parse(chosen_arguments)
    verified_arguments = arguments.verify(parsed_arguments)
    assert verified_arguments is False
Exemplo n.º 5
0
def test_directory_argument_verifiable(correct_arguments):
    """Check that valid directory arguments will verify correctly"""
    parsed_arguments = arguments.parse(correct_arguments)
    verified_arguments = arguments.verify(parsed_arguments)
    assert verified_arguments is True
Exemplo n.º 6
0
def test_configuration_file_saved(correct_arguments, tmpdir):
    """Checks that the configuration file was saved to the directory"""
    parsed_arguments = arguments.parse(correct_arguments)
    configuration.save(
        str(tmpdir) + "/" + constants.CONFIGURATION, vars(parsed_arguments))
    assert len(tmpdir.listdir()) == 1
Exemplo n.º 7
0
import perf

from tada.util import arguments
from tada.util import configuration
from tada.util import constants
from tada.util import display
from tada.util import package
from tada.util import run
from tada.util import save

if __name__ == "__main__":
    current_size = constants.SIZE_START
    # display the welcome message
    display.display_welcome_message()
    # read and verify the command-line arguments
    tada_arguments = arguments.parse(sys.argv[1:])
    did_verify_arguments = arguments.verify(tada_arguments)
    # incorrect arguments, exit program
    if did_verify_arguments is False:
        print("Incorrect command-line arguments.")
        sys.exit(constants.INCORRECT_ARGUMENTS)
    # correct arguments, run doubling experiment
    else:
        # add the directory to the sys.path
        package.add_sys_path(tada_arguments.directory)
        # create and save a configuration dictionary from the arguments
        configuration.save(constants.CONFIGURATION, vars(tada_arguments))
        # save the size of the experiment in the constants.file
        save.save_experiment_size(constants.SIZE, current_size)
        # save the directory containing functions to be analyzed
        save.save_directory(constants.DIRECTORY, tada_arguments.directory)