def static_analisys(application): """ Performs a pyflakes static analysis with the same configuration as django CMS testsuite """ try: from cms.test_utils.util.static_analysis import pyflakes application_module = import_module(application) assert pyflakes((application_module, )) == 0 except ImportError: print(u"Static analisys available only if django CMS is installed")
def static_analisys(application): """ Performs a pyflakes static analysis with the same configuration as django CMS testsuite """ try: from cms.test_utils.util.static_analysis import pyflakes application_module = import_module(application) assert pyflakes((application_module,)) == 0 except ImportError: print(u"Static analisys available only if django CMS is installed")
def static_analisys(application): """ Performs a pyflakes static analysis with the same configuration as django CMS testsuite """ try: from cms.test_utils.util.static_analysis import pyflakes application_module = __import__(application) report = pyflakes((application_module, )) if type(report) == tuple: assert report[0] == 0 else: assert report == 0 except ImportError: print('Static analysis available only if django CMS is installed')
def static_analisys(application): """ Performs a pyflakes static analysis with the same configuration as django CMS testsuite """ try: from cms.test_utils.util.static_analysis import pyflakes application_module = __import__(application) report = pyflakes((application_module,)) if type(report) == tuple: assert report[0] == 0 else: assert report == 0 except ImportError: print('Static analisys available only if django CMS is installed')
def test_pyflakes(self): import cms import menus errors, message = pyflakes((cms, menus)) self.assertEqual(errors, 0, message)
def main(): args = docopt(__doc__, version=cms.__version__) if args['pyflakes']: return static_analysis.pyflakes() if args['authors']: return generate_authors() # configure django warnings.filterwarnings( 'error', r"DateTimeField received a naive datetime", RuntimeWarning, r'django\.db\.models\.fields') default_name = ':memory:' if args['test'] else 'local.sqlite' db_url = os.environ.get("DATABASE_URL", "sqlite://localhost/%s" % default_name) migrate = args.get('--migrate', False) with temp_dir() as STATIC_ROOT: with temp_dir() as MEDIA_ROOT: use_tz = VERSION[:2] >= (1, 4) configs = { 'db_url': db_url, 'ROOT_URLCONF': 'cms.test_utils.project.urls', 'STATIC_ROOT': STATIC_ROOT, 'MEDIA_ROOT': MEDIA_ROOT, 'USE_TZ': use_tz, 'SOUTH_TESTS_MIGRATE': migrate, } if args['test']: configs['SESSION_ENGINE'] = "django.contrib.sessions.backends.cache" # Command line option takes precedent over environment variable auth_user_model = args['--user'] if not auth_user_model: auth_user_model = os.environ.get("AUTH_USER_MODEL", None) if auth_user_model: if VERSION[:2] < (1, 5): print() print("Custom user models are not supported before Django 1.5") print() else: configs['AUTH_USER_MODEL'] = auth_user_model configure(**configs) # run if args['test']: # make "Address already in use" errors less likely, see Django # docs for more details on this env variable. os.environ.setdefault( 'DJANGO_LIVE_TEST_SERVER_ADDRESS', 'localhost:8000-9000' ) if args['--xvfb']: import xvfbwrapper context = xvfbwrapper.Xvfb(width=1280, height=720) else: @contextlib.contextmanager def null_context(): yield context = null_context() with context: if args['isolated']: failures = isolated(args['<test-label>'], args['--parallel']) print() print("Failed tests") print("============") if failures: for failure in failures: print(" - %s" % failure) else: print(" None") num_failures = len(failures) elif args['timed']: num_failures = timed(args['<test-label>']) else: num_failures = test(args['<test-label>'], args['--parallel'], args['--failfast']) sys.exit(num_failures) elif args['server']: server(args['--bind'], args['--port'], migrate) elif args['shell']: shell() elif args['compilemessages']: compilemessages() elif args['makemessages']: compilemessages()
def test_pyflakes(self): self.assertEqual(pyflakes(), 0)
def main(): args = docopt(__doc__, version=cms.__version__) if args['pyflakes']: return static_analysis.pyflakes() if args['authors']: return generate_authors() # configure django warnings.filterwarnings('error', r"DateTimeField received a naive datetime", RuntimeWarning, r'django\.db\.models\.fields') default_name = ':memory:' if args['test'] else 'local.sqlite' db_url = os.environ.get("DATABASE_URL", "sqlite://localhost/%s" % default_name) migrate = args.get('--migrate', False) with temp_dir() as STATIC_ROOT: with temp_dir() as MEDIA_ROOT: use_tz = VERSION[:2] >= (1, 4) configs = { 'db_url': db_url, 'ROOT_URLCONF': 'cms.test_utils.project.urls', 'STATIC_ROOT': STATIC_ROOT, 'MEDIA_ROOT': MEDIA_ROOT, 'USE_TZ': use_tz, 'SOUTH_TESTS_MIGRATE': migrate, } if args['test']: configs[ 'SESSION_ENGINE'] = "django.contrib.sessions.backends.cache" # Command line option takes precedent over environment variable auth_user_model = args['--user'] if not auth_user_model: auth_user_model = os.environ.get("AUTH_USER_MODEL", None) if auth_user_model: if VERSION[:2] < (1, 5): print() print( "Custom user models are not supported before Django 1.5" ) print() else: configs['AUTH_USER_MODEL'] = auth_user_model configure(**configs) # run if args['test']: # make "Address already in use" errors less likely, see Django # docs for more details on this env variable. os.environ.setdefault('DJANGO_LIVE_TEST_SERVER_ADDRESS', 'localhost:8000-9000') if args['--xvfb']: import xvfbwrapper context = xvfbwrapper.Xvfb(width=1280, height=720) else: @contextlib.contextmanager def null_context(): yield context = null_context() with context: if args['isolated']: failures = isolated(args['<test-label>'], args['--parallel']) print() print("Failed tests") print("============") if failures: for failure in failures: print(" - %s" % failure) else: print(" None") num_failures = len(failures) elif args['timed']: num_failures = timed(args['<test-label>']) else: num_failures = test(args['<test-label>'], args['--parallel'], args['--failfast']) sys.exit(num_failures) elif args['server']: server(args['--bind'], args['--port'], args.get('--migrate', True)) elif args['shell']: shell() elif args['compilemessages']: compilemessages() elif args['makemessages']: makemessages() elif args['makemigrations']: makemigrations()
def main(): args = docopt(__doc__, version=cms.__version__) if args["pyflakes"]: return static_analysis.pyflakes() if args["authors"]: return generate_authors() # configure django warnings.filterwarnings( "error", r"DateTimeField received a naive datetime", RuntimeWarning, r"django\.db\.models\.fields" ) default_name = ":memory:" if args["test"] else "local.sqlite" db_url = os.environ.get("DATABASE_URL", "sqlite://localhost/%s" % default_name) migrate = args.get("--migrate", False) with temp_dir() as STATIC_ROOT: with temp_dir() as MEDIA_ROOT: use_tz = VERSION[:2] >= (1, 4) configs = { "db_url": db_url, "ROOT_URLCONF": "cms.test_utils.project.urls", "STATIC_ROOT": STATIC_ROOT, "MEDIA_ROOT": MEDIA_ROOT, "USE_TZ": use_tz, "SOUTH_TESTS_MIGRATE": migrate, } if args["test"]: configs["SESSION_ENGINE"] = "django.contrib.sessions.backends.cache" # Command line option takes precedent over environment variable auth_user_model = args["--user"] if not auth_user_model: auth_user_model = os.environ.get("AUTH_USER_MODEL", None) if auth_user_model: if VERSION[:2] < (1, 5): print() print("Custom user models are not supported before Django 1.5") print() else: configs["AUTH_USER_MODEL"] = auth_user_model configure(**configs) # run if args["test"]: # make "Address already in use" errors less likely, see Django # docs for more details on this env variable. os.environ.setdefault("DJANGO_LIVE_TEST_SERVER_ADDRESS", "localhost:8000-9000") if args["--xvfb"]: import xvfbwrapper context = xvfbwrapper.Xvfb(width=1280, height=720) else: @contextlib.contextmanager def null_context(): yield context = null_context() with context: if args["isolated"]: failures = isolated(args["<test-label>"], args["--parallel"]) print() print("Failed tests") print("============") if failures: for failure in failures: print(" - %s" % failure) else: print(" None") num_failures = len(failures) elif args["timed"]: num_failures = timed(args["<test-label>"]) else: num_failures = test(args["<test-label>"], args["--parallel"], args["--failfast"]) sys.exit(num_failures) elif args["server"]: server(args["--bind"], args["--port"], args.get("--migrate", True)) elif args["shell"]: shell() elif args["compilemessages"]: compilemessages() elif args["makemessages"]: makemessages() elif args["makemigrations"]: makemigrations()
def test_pyflakes(self): import cms import menus self.assertEqual(pyflakes((cms, menus)), 0)