def main():
    pytest_configure({})
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)
def run_django_tests(args):
    """This will only work with a later version of Django (1.8?)"""
    from django.core.exceptions import ImproperlyConfigured

    try:
        from django.test.utils import get_runner
        from tests.conftest import pytest_configure

        settings = pytest_configure()
        TestRunner = get_runner(settings)
        test_runner = TestRunner()
        exit_on_failure(test_runner.run_tests(args))

    except ImproperlyConfigured:
        sys.exit('TEST #FAIL: The --django arg has only been tested with 1.8')
Exemple #3
0
def run_django_tests(args):
    """This will only work with a later version of Django (1.8?)"""
    from django.core.exceptions import ImproperlyConfigured

    try:
        from django.test.utils import get_runner
        from tests.conftest import pytest_configure

        settings = pytest_configure()
        TestRunner = get_runner(settings)
        test_runner = TestRunner()
        exit_on_failure(test_runner.run_tests(args))

    except ImproperlyConfigured:
        sys.exit('TEST #FAIL: The --django arg has only been tested with 1.8')
Exemple #4
0
#!/usr/bin/env python
import os
import subprocess
import sys
"""
Creates a database with fixtures and launches a local server.
"""

if __name__ == "__main__":

    from django.core.management import execute_from_command_line
    from tests.conftest import pytest_configure
    # we use the same settings than in the unit tests
    # except for the js file
    pytest_configure()
    # now we load the settings
    from django.conf import settings
    # we ensure the user is running "python migrations.py makemigrations rest_messaging"
    if all(arg in ['runtestapplication.py'] for arg in sys.argv[:1]):
        # execute the following command if you want to remove the old database
        # execute_from_command_line(['django-admin', 'flush'])
        # we make the migrations
        execute_from_command_line(['django-admin', 'migrate'])
        # to create a fixture.json file, run the command on next line
        # execute_from_command_line(['django-admin', 'dumpdata', '-o', 'fixtures.json', '--exclude', 'contenttypes', '--exclude', 'auth.Permission'])
        # we load the fixtures
        execute_from_command_line(
            ['django-admin', 'loaddata', 'fixtures.json'])
        # we start centrifugo
        try:
            # we launch centrifugo if not done yet
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
from tests.conftest import pytest_configure

if __name__ == "__main__":

    pytest_configure()

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)
#!/usr/bin/env python
import os
import subprocess
import sys

"""
Creates a database with fixtures and launches a local server.
"""

if __name__ == "__main__":
    
    from django.core.management import execute_from_command_line
    from tests.conftest import pytest_configure
    pytest_configure(database_name='runtestapplication.db')  # we use the same settings than in the unit tests
    from django.conf import settings

    # we ensure the user is running "python migrations.py makemigrations rest_messaging"
    if all(arg in ['runtestcronmessages.py'] for arg in sys.argv[:1]):
        # we start messaging cron jobs, to ensure the messages are pushed in real time
        execute_from_command_line(['django-admin', 'runcrons', 'tests.cron_messages.CronMessages'])
    else:
        raise Exception('Error: could not launch test server.')
Exemple #7
0
#!/usr/bin/env python
import os
import subprocess
import sys
"""
Creates a database with fixtures and launches a local server.
"""

if __name__ == "__main__":

    from django.core.management import execute_from_command_line
    from tests.conftest import pytest_configure
    pytest_configure(database_name='runtestapplication.db'
                     )  # we use the same settings than in the unit tests
    from django.conf import settings

    # we ensure the user is running "python migrations.py makemigrations rest_messaging"
    if all(arg in ['runtestcronmessages.py'] for arg in sys.argv[:1]):
        # we start messaging cron jobs, to ensure the messages are pushed in real time
        execute_from_command_line(
            ['django-admin', 'runcrons', 'tests.cron_messages.CronMessages'])
    else:
        raise Exception('Error: could not launch test server.')