Esempio n. 1
0
def test(resource, url):
    """
    Test api. You can specify a resource (like api_1.user) for single testing.
    By default all resources will be tested.
    """
    from tests import run
    run(url, resource)
Esempio n. 2
0
def test():
    createdb(drop_first=True)
    """Runs unit tests"""
    tests.run()
    CONFIG.set('default', 'env', 'dev')
    with open('config.cfg', 'w') as configfile:
        CONFIG.write(configfile)
Esempio n. 3
0
def test(resource=None):
    try:
        import pyresttest
    except ImportError:
        print ' *** please install/update requirements or fix the problem ***'
        traceback.print_exc(file=sys.stdout)
        exit(0)
    from tests import run
    run(resource)
def main (**kwargs):
    pattern = os.path.join(os.path.dirname(__file__), '*_test.py');
    all_tests = []

    for path in glob(pattern):
        name = os.path.splitext(os.path.basename(path))[0]
        test = __import__(name)
        all_tests.append(test.suite())

    tests.run(*all_tests, **kwargs)
Esempio n. 5
0
    def setUp(self):
        self.tmp_dir = '/tmp/'
        self.project_name = 'test-project'
        self.django_project_name = 'testproject'
        self.project_path = os.path.join(self.tmp_dir, self.project_name)
        if os.path.exists(self.project_path):
            shutil.rmtree(self.project_path)

        run('duke startproject %s -m -b %s' \
                % (self.project_name, self.tmp_dir))
Esempio n. 6
0
def run():
    print >> sys.stderr
    print >> sys.stderr, '#' * 60
    print >> sys.stderr, 'DPMI Visualizer 0.7'
    print >> sys.stderr, '(c) 2011-2013 David Sveningsson <*****@*****.**>'
    print >> sys.stderr, 'GNU GPLv3'
    print >> sys.stderr

    parser = argparse.ArgumentParser(epilog=usage(), formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument('-f', '--config', default=None, help='Configuration-file')
    parser.add_argument('-H', dest='plugin', type=str, metavar='PLUGIN', help="Show help for plugin")
    parser.add_argument('--test', action='store_true', help="Run tests")
    args = parser.parse_args()

    if args.plugin:
        plugin.usage(args.plugin)
        sys.exit(0)

    if args.test:
        import tests
        tests.run() # calls sys.exit

    log = setup_logging()

    if not args.config:
        if not os.path.exists('visualizer.conf'):
            print >> sys.stderr, 'No config-file specified and "visualizer.conf" not found'
            sys.exit(1)
        args.config = 'visualizer.conf'
    if not os.path.exists(args.config):
        print >> sys.stderr, 'Failed to load configuration from %s: No such file or directory' % args.config
        sys.exit(1)

    # parse config
    cfg = config.read(args.config)

    pidlock = cfg.get('general/lockfile')
    if os.path.exists(pidlock):
        print >> sys.stderr, pidlock, 'exists, if the visualizer isn\'t running manually remove the file before continuing'
        sys.exit(1)

    with open(pidlock, 'w') as pid:
        pid.write(str(os.getpid()))

    try:
        main = Main(cfg, filename=args.config)
        gtk.main()
    finally:
        os.unlink(pidlock)

    log.debug('Visualizer stopped')
Esempio n. 7
0
 def run(self, args):
     print('Running tests')
     if args.coverage:
         print(
             '\t --coverage is enabled, run `coverage report -m` to view coverage report'
         )
         argv = [
             'coverage', 'run', '--source', 'squad_client', '-m',
             'unittest', 'discover'
         ]
         return os.execvp('coverage', argv)
     else:
         tests.run()
         return True
Esempio n. 8
0
def main():
    '''Launch function'''
    colorama.init()

    utils.log.do_show_debug_messages = PARSED_ARGS.debug

    # Launch test suite?
    if PARSED_ARGS.test:
        log.info("running chessreader test base")
        tests.run()
        sys.exit(0)

    # default: call the shell
    core.Shell().cmdloop()

    sys.exit(0)
    def test_existing_target(self):
        self.setUp()
        StartprojectCommand().call(self.project_name, \
                base_path=self.tmp_dir, minimal=True)

        stdout, stderr, returncode = \
                run('duke startproject %s -m -b %s' \
                % (self.project_name, self.tmp_dir))

        self.assertTrue(stdout.startswith('Error:'))
    def test_existing_target(self):
        self.setUp()
        StartprojectCommand().call(self.project_name, \
                base_path=self.tmp_dir, minimal=True)

        stdout, stderr, returncode = \
                run('duke startproject %s -m -b %s' \
                % (self.project_name, self.tmp_dir))

        self.assertTrue(stdout.startswith('Error:'))
    def test_cli_minimal(self):
        self.setUp()
        stdout, stderr, returncode = \
                run('duke startproject %s -m -b %s' \
                % (self.project_name, self.tmp_dir))

        self.assertTrue(stdout.startswith('Created project %s' \
                % self.project_name))
        self.assertEquals(0, returncode)
        self.assertTrue(self._path_exists('setup.py'))
        self.assertFalse(self._path_exists('README.rst'))
        self.assertFalse(self._path_exists('LICENSE'))
    def test_cli_minimal(self):
        self.setUp()
        stdout, stderr, returncode = \
                run('duke startproject %s -m -b %s' \
                % (self.project_name, self.tmp_dir))

        self.assertTrue(stdout.startswith('Created project %s' \
                % self.project_name))
        self.assertEquals(0, returncode)
        self.assertTrue(self._path_exists('setup.py'))
        self.assertFalse(self._path_exists('README.rst'))
        self.assertFalse(self._path_exists('LICENSE'))
Esempio n. 13
0
    def run(self):
        import importlib
        import tests

        failures = tests.run(self.suites)

        print('')
        print('All test suites completed with %d failed tests' % len(failures))
        if failures:
            sys.stderr.write('Failed tests:\n%s\n' %
                             '\n'.join('\t%s - %s' % (test.name, test.message)
                                       for test in failures))
        sys.exit(len(failures))
Esempio n. 14
0
    def run(self):
        import importlib
        import tests

        failures = tests.run(self.suites)

        print('')
        print('All test suites completed with %d failed tests' % len(failures))
        if failures:
            sys.stderr.write('Failed tests:\n%s\n' % '\n'.join(
                '\t%s - %s' % (test.name, test.message)
                    for test in failures))
        sys.exit(len(failures))
Esempio n. 15
0
    def test_initialize(self):
        self.setUp()
        stdout, stderr, returncode = \
                run('duke init %s -n -b %s' % \
                (self.django_project_name, self.project_path))

        self.assertEquals(0, returncode)
        global_conf = os.path.join(os.getenv("HOME"), '.duke/duke_conf.yml')
        self.assertTrue(self._path_exists(global_conf))
        self.assertTrue(self._path_exists('bootstrap.py'))
        self.assertTrue(self._path_exists('buildout.cfg'))
        self.assertTrue(self._path_exists('dev.cfg'))
        self.assertTrue(self._path_exists('.duke/'))
        self.assertTrue(self._path_exists('.duke/base.cfg'))
        self.assertTrue(self._path_exists('.duke/project_conf.yml'))
        self.assertTrue(self._path_exists('.duke/bin/dev'))
        self.assertTrue(self._path_exists('.duke/bin/env'))
        self.assertTrue(self._path_exists('.duke/bin/profile'))
Esempio n. 16
0
    def run(self):
        import importlib
        import tests

        self.run_command('dependencies')

        failures = tests.run(self.test_suites)
        if failures is None:
            print('Test suite was cancelled by setup')
            sys.exit(-1)

        print('')
        print('All test suites completed with %d failed tests' % len(failures))
        if failures:
            sys.stderr.write('Failed tests:\n%s\n' % '\n'.join(
                '\t%s - %s' % (test.name, test.message)
                    for test in failures))
        sys.exit(len(failures))
Esempio n. 17
0
    if not (rmsds == expected).all():
        return False, "Written RMSDs do not equal expected values"

    os.unlink(xtcout)
    return True, ()


def test_TRRFile():
    trrin = os.path.join(tests.mydir, "test.trr")
    xtcout = "/tmp/testout.xtc"

    with xdr.TRRFile(trrin) as trr, xdr.XTCFile(xtcout, "w", overwrite=True) as xtc:
        for fr, frame in enumerate(trr):
            xtcframe = xdr.XTCFrame(frame.coords, fr, frame.time, box=frame.box)
            xtc.write(xtcframe)

    topol = os.path.join(tests.mydir, "test.pdb")
    rmsds = get_rmsds(trrin, topol)
    expected = get_rmsds(xtcout, topol)

    diff = abs(rmsds - expected)
    epsilon = 10e-5

    if diff.max() > epsilon:
        return False, "Written RMSDs do not equal expected values. Max diff: %s e: %s" % (diff.max(), epsilon)

    return True, ()


tests.run(test_XTCFile, test_TRRFile)
Esempio n. 18
0
import socket
import ftp_conn
import config
import server
import tests

config = config.Configuration()

if config.mode == 'server':
    server.run(config)
elif config.mode == 'tests':
    tests.run(config)
Esempio n. 19
0
File: setup.py Progetto: acg/lwpb
    def run(self):
        import tests

        tests.run("test/test.proto.pb", "test/truthdb.txt")
Esempio n. 20
0
#!/usr/bin/env python

""" pykwalify - script entry point """

__author__ = 'Grokzen <*****@*****.**>'

import sys
import os

# Check if we are installed in the system already, otherwise update path
(prefix, bindir) = os.path.split(os.path.dirname(os.path.abspath(sys.argv[0])))
if bindir == 'bin':
    # Assume we are installed on the system
    pass
else:
    # Assume we are not yet installed
    sys.path.append(os.path.join(prefix, bindir, 'lib'))

sys.path.append(os.getcwd())

if __name__ == '__main__':
    import tests
    tests.run(sys.argv)
Esempio n. 21
0
def test(args):
    tests.run()
Esempio n. 22
0
from tests import run, findQtProjects
import platform

if platform.system() == "Windows":
    MAKE="mingw32-make"
else:
    MAKE="make"

projects = findQtProjects()

topdir=os.path.abspath(".")
print "Build tests...",
for project in projects:
    print project,
    project_dir, project_name = os.path.split(project)
    
    os.chdir(topdir)
    os.chdir(project_dir)
    
    if 0 != run("qmake", [project_name]):
        print "qmake failed",
        continue
	
    if 0 != run(MAKE, ["debug", "-j4"]):
        print "make failed",
        # TODO maybe output a warning
        continue
        
print "Done"

Esempio n. 23
0
        if i == somme:
            res.append(i)

    return res


# tests case
test_cases = [
    {
        "args": {
            'borne': 9000
        },
        "result": [6, 28, 496, 8128]
    },
    {
        "args": {
            'borne': 3
        },
        "result": None
    },
    {
        "args": {
            'borne': 500
        },
        "result": [6, 28, 496]
    },
]

run(perfect_nb, test_cases)
Esempio n. 24
0
def runTests(parser):
    import tests
    tests.run(parser)
Esempio n. 25
0
    options = parser.parse_args(sys.argv[1:])

    logging.basicConfig(
        filename=None,
        level=logging.DEBUG if options.verbose else logging.INFO,
        format="%(asctime)s: %(levelname)7s: %(message)s",
        datefmt="%H:%M:%S",
    )

    logging.getLogger("requests").setLevel(logging.ERROR)

    result = tests.run(
        options.dest_host,
        options.dest_port,
        options.https,
        options.timeout,
        options.tests,
        options.first_error,
        options.verbose,
    )
    if result is None:
        sys.exit(-1)

    (all, passed) = result
    if len(all) == len(passed):
        sys.exit(0)

    else:
        sys.exit(-1)
Esempio n. 26
0
	def run(self, edit):
		reload_modules()
		reload_modules()
		tests.run(self.view, edit)
def runtests(args):
    from tests import run
    run(verbosity=args.verbosity)
 def test_args_length(self):
     self.setUp()
     stdout, stderr, returncode = run('duke startproject')
     self.assertTrue(stdout.startswith('Error:'))
Esempio n. 29
0
 def run(self, edit):
     reload_test_bootstrap()
     tests.run(self.view, edit)
Esempio n. 30
0
    elif args.run:
        # project imports
        try:
            from project import app
            from project.application import configure_app
            from project.config import DefaultConfig, DevelopmentConfig, ProductionConfig
        except ImportError:
            print ' *** please install/update requirements or fix the problem ***'
            traceback.print_exc(file=sys.stdout)
            exit(0)

        if args.conf_obj:
            conf_obj = args.conf_obj[0]
            if conf_obj == 'develop':
                develop()
            elif conf_obj == 'product':
                product()
            else:
                print "error: undefined config '%s'" % conf_obj
                exit(0)

        if args.conf_file:
            import_local_config_file(args.conf_file[0])

        run()

    else:
        parser.print_help()

Esempio n. 31
0
test_dirs=[]
for project in findQtProjects():
    test_dirs.append(os.path.split(project)[0])

log_file=open("run_all_tests.log", "w")

for test_dir in test_dirs:
    test_name = os.path.split(test_dir)[1]
    exename = "%s/debug/%s%s" % (test_dir, test_name, exe_suffix)
    test_logname = "%s/%s.log" % (test_dir, test_name)
    
    print "Running test '%s'..." % test_dir,
    
    if not os.path.isfile(exename):
        # probably a compilation error
        print "NOT FOUND"
        continue
        
    result = run(exename, ["-o", test_logname])
    
    if 0 == result:
        print "OK"
    else:
        print "%d FAILED" % result
    
    # Logfile ans globale anfuegen
    log_file.write(open(test_logname, "r").read())


Esempio n. 32
0
                      '--coverage',
                      action='store_true',
                      help='Measure code coverage')

options, args = parser.parse_args()
if args:
    parser.print_help()
    sys.exit(2)

if coverage and options.coverage:
    cov = coverage()
    cov.start()

# Import the Stango code down here to make coverage count the importing, too
import tests
result = tests.run(options.verbose)

if result.wasSuccessful() and options.coverage:
    exclude = [
        'stango.tests',
        'stango.autoreload',
    ]

    def include_module(name):
        # exclude test code and stango.autoreload which is not testable
        for prefix in ['stango.tests', 'stango.autoreload']:
            if name.startswith(prefix):
                return False
        return name.startswith('stango')

    cov.stop()
Esempio n. 33
0
###DO NOT MODIFY CODE BELOW THIS LINE###

#All problems that cause exceptions should be addressed here
try:
    function(*inputs[0])
except SyntaxError as e:
    s = traceback.format_exc(e)
    f = open('output.txt', 'w')
    f.write(s)
    sys.exit("Student code has a Syntax Error. Shutting down autograder")
except TypeError as e:
    s = traceback.format_exc(e)
    f = open('output.txt', 'w')
    f.write(s)
    sys.exit("Student code has incorrect number of input parameters. Shutting down autograder")
except AttributeError as e:
    s = traceback.format_exc(e)
    f = open('output.txt', 'w')
    f.write(s)
    sys.exit("Function not found in code. Shutting down autograder.")
except Exception as e:
    s = traceback.format_exc(e)
    f = open('output.txt', 'w')
    f.write(s)
    sys.exit("There is an error in the student's code that causes a crash. Shutting down autograder")

#Battery of tests here.
#If all outputs are correct, then the code is considered to be 100% correct
tests.run(inputs, correct, function)
print("Code successfully tested. Check output.txt for details.")
Esempio n. 34
0
import os
import sys

import tests
from tests.suites import *


failures = tests.run()
if failures is None:
    print('Test suite was cancelled by setup')
    sys.exit(-1)


print('')
print('All test suites completed with %d failed tests' % len(failures))
if failures:
    sys.stderr.write('Failed tests:\n%s\n' % '\n'.join(
        '\t%s - %s' % (test.name, test.message)
            for test in failures))
sys.exit(len(failures))
Esempio n. 35
0
def main():
    tests.run()
Esempio n. 36
0
    return int_list


# 1.0s
run(tri_iteratif, [{
    'args': {
        'int_list': [14, 7, 3, 18, 23]
    },
    'result': [3, 7, 14, 18, 23]
}, {
    'args': {
        'int_list': [0.1, 4, 3, 3, 72]
    },
    'result': [0.1, 3, 3, 4, 72]
}, {
    'args': {
        'int_list': [120, 47, 3, 18, 1, 2.5]
    },
    'result': [1, 2.5, 3, 18, 47, 120]
}, {
    'args': {
        'int_list': [1, 2, 3, 4, 5]
    },
    'result': [1, 2, 3, 4, 5]
}, {
    'args': {
        'int_list': [5, 4, 3, 2, 1]
    },
    'result': [1, 2, 3, 4, 5]
}])
Esempio n. 37
0
    def test_help(self):
        stdout, stderr, returncode = run('duke -h')

        self.assertTrue(stdout.startswith('usage: duke [command] [options]'))
        self.assertEquals(1, returncode)
#!/usr/bin/env python

import tests
import os, sys

if len(sys.argv) > 1 and sys.argv[1] == "update":
    if len(sys.argv) > 2:
        config = tests.get_config(os.path.dirname(sys.argv[2]))
        root, ext = os.path.splitext(sys.argv[2])
        if ext == config.get(tests.get_section(os.path.basename(root), config), 'input_ext'):
            tests.generate(root, config)
        else:
            print(sys.argv[2], 'does not have a valid file extension. Check config.')
    else:
        tests.generate_all()
else:
    tests.run()
Esempio n. 39
0
#!/usr/bin/env python
""" pykwalify - script entry point """

__author__ = 'Grokzen <*****@*****.**>'

import sys
import os

# Check if we are installed in the system already, otherwise update path
(prefix, bindir) = os.path.split(os.path.dirname(os.path.abspath(sys.argv[0])))
if bindir == 'bin':
    # Assume we are installed on the system
    pass
else:
    # Assume we are not yet installed
    sys.path.append(os.path.join(prefix, bindir, 'lib'))

sys.path.append(os.getcwd())

if __name__ == '__main__':
    import tests
    tests.run(sys.argv)
Esempio n. 40
0
        digest = finalised.squeeze(self.digest_size)
        return KeccakState.bytes2str(digest)

    def hexdigest(self):
        return self.digest().encode('hex')

    @staticmethod
    def preset(bitrate_bits, capacity_bits, output_bits):
        """
        Returns a factory function for the given bitrate, sponge capacity and output length.
        The function accepts an optional initial input, ala hashlib.
        """
        def create(initial_input=None):
            h = KeccakHash(bitrate_bits, capacity_bits, output_bits)
            if initial_input is not None:
                h.update(initial_input)
            return h

        return create


# SHA3 parameter presets
Keccak224 = KeccakHash.preset(1152, 448, 224)
Keccak256 = KeccakHash.preset(1088, 512, 256)
Keccak384 = KeccakHash.preset(832, 768, 384)
Keccak512 = KeccakHash.preset(576, 1024, 512)

if __name__ == '__main__':
    import tests
    tests.run()
Esempio n. 41
0
#!/usr/bin/env python

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException



import tests

driver = webdriver.Firefox()

try:
    tests.run(driver)

finally:
    driver.quit()
Esempio n. 42
0
 def test_args_length(self):
     self.setUp()
     stdout, stderr, returncode = run('duke init')
     self.assertEquals(1, returncode)
     self.assertTrue(stdout.startswith('Error:'))
        Popen(["date", "-s", date]).wait()
    except:
        pass

global R

def setup():
    global R
    R = Robot.setup()
    R.init()
    set_time(R.usbkey)
    logger = setup_logger(R.usbkey)
    logger.info('Battery Voltage: %.2f' % R.power.battery.voltage)
    R.wait_start()
    try:
        io = IOInterface(R)
    except:
        logger.exception("IOInterface could not initialize")
        raise
    return logger, io, R.zone

if __name__ == '__main__' or __name__ == '__builtin__':
    logger, io, corner = setup()
    if RUN_TESTS:
        import tests
        global R
        tests.run(logger, io, R)
    else:
        import gamelogic
        gamelogic.PlayGame(logger, io, corner)
Esempio n. 44
0
 def run(self, args):
     logger.info('Running tests')
     return tests.run(args.coverage, args.tests, args.verbose)
Esempio n. 45
0
File: test.py Progetto: nirs/hpy
""" Run tests

usage: test [name-specifiers]

To run all tests::

    test
    
To run specific tests module::

    test test_foo
    
To run specific test case::

    test test_foo.test_case
    
To run specific test method::

    test test_foo.test_case.test_this
"""

import sys
import tests

# run expect fully qualified names
names = ['tests.' + name for name in sys.argv[1:]]

result = tests.run(*names)
sys.exit(not result.wasSuccessful())
Esempio n. 46
0
        return sequence[query - 1]
    else:
        sequence = syracuse(start, query, sequence)

    return sequence


run(syracuse, [
    {
        'args': {
            'start': 14,
            'query': 5
        },
        'result': 34
    },
    {
        'args': {
            'start': 14,
            'query': 2
        },
        'result': 7
    },
    {
        'args': {
            'start': 14,
            'query': 1
        },
        'result': 14
    },
])
Esempio n. 47
0
options, args = parser.parse_args()
if args:
    parser.print_help()
    sys.exit(2)

if coverage and options.coverage:
    cov = coverage()
    cov.start()
elif not coverage and options.coverage:
    print >>sys.stderr, "Coverage module not found"
    sys.exit(1)

import tests

result = tests.run(options.verbose)

if result.wasSuccessful() and options.coverage:
    exclude = ["tirsk.tests"]

    def include_module(name):
        # exclude test code
        for prefix in exclude:
            if name.startswith(prefix):
                return False
        return name.startswith("tirsk")

    cov.stop()
    modules = [module for name, module in sys.modules.items() if include_module(name)]
    cov.report(modules, file=sys.stdout)
    cov.erase()
Esempio n. 48
0
 def loadTests(self):
     import tests
     self.tests = [
         t(self.tester) for t in tests.run() if t.__name__ != 'ExampleTest'
     ]
Esempio n. 49
0
args = parser.parse_args()

if args.command == 'sentry':
    sentry.createConfig(args.path, args.dsn)

elif args.command == 'add-languages':
    loc = localization.Localization(
        "locales\\*.resx",
        '.\src\\ProtonVPN.Translations\\Properties\\Resources.{lang}.resx',
        '.\\src\\bin\\ProtonVPN.MarkupValidator.exe')
    returnCode = loc.AddLanguages()
    sys.exit(returnCode)

elif args.command == 'tests':
    tests.run('{path}*.Test.dll'.format(path=args.path))

elif args.command == 'sign':
    signing.sign()

elif args.command == 'app-installer':
    v = win32api.GetFileVersionInfo('.\src\\bin\ProtonVPN.exe', '\\')
    semVersion = "%d.%d.%d" % (v['FileVersionMS'] / 65536, v['FileVersionMS'] % 65536, v['FileVersionLS'] / 65536)
    params = ''
    p = Path()
    for f in list(p.glob('.\src\\bin\**\ProtonVPN.Translations.resources.dll')):
        params = params + "\r\nAddFolder APPDIR {folder}".format(folder=f.parent.absolute())

    print('Building app installer')
    err = installer.build(semVersion, args.hash, 'Setup/ProtonVPN.aip', params)
    sys.exit(err)