Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@that_with_context(prepare_stuff, and_cleanup_the_mess)
def test_running_unit_n_functional_without_labels(context, nose_run):
u"if get --unit but also --functional then it should use a test database"
context.options['is_unit'] = True
context.options['is_functional'] = True
context.runner.get_apps = mock.Mock()
context.runner.get_apps.return_value = ['john', 'doe']
context.runner.get_nose_argv = mock.Mock()
context.runner.get_nose_argv.return_value = ['nose', 'argv']
context.runner.get_paths_for = mock.Mock()
expected_kinds = ['unit', 'functional']
@sure.that_with_context([setup1, setup2])
def john_is_within_context(context):
assert context.first_name == 'John'
assert context.last_name == 'Resig'
@that_with_context(prepare_stuff, and_cleanup_the_mess)
def test_get_argv_options_functional(context):
u"Nose should parse sys.argv and figure out whether to run as functional"
sys.argv = ['./manage.py', 'test', '--functional']
runner = Nose()
opts = runner.get_argv_options()
assert that(opts['is_unit']).equals(False)
assert that(opts['is_functional']).equals(True)
assert that(opts['is_integration']).equals(False)
@sure.that_with_context(setup)
def it_crashes():
assert True
@that_with_context(prepare_stuff, and_cleanup_the_mess)
def test_should_try_loading_test_cmd_class(context,
load_command_class,
get_commands):
u"Nose should try loading the 'test' command class"
sys.argv = ['./manage.py', 'test',
'--unit', '--functional', '--integration']
runner = Nose()
command_mock = mock.Mock()
get_commands.return_value = {'test': 'string to load'}
load_command_class.return_value = command_mock
command_mock.option_list = []
opts = runner.get_argv_options()
assert that(opts['is_unit']).equals(True)
assert that(opts['is_functional']).equals(True)
@that_with_context(prepare_stuff, and_cleanup_the_mess)
def test_get_paths_ignore_paths_that_doesnt_exist(context,
find_module,
load_module,
exists):
u"get_paths_for ignore paths that doesn't exist"
module_mock = mock.Mock()
module_mock.__file__ = '/path/to/file.py'
find_module.return_value = ('file', 'pathname', 'description')
load_module.return_value = module_mock
exists.return_value = False
expected_path = context.runner.get_paths_for(
['bazfoobar'],
appending=['one', 'more', 'place'],
@that_with_context(prepare_stuff, and_cleanup_the_mess)
def test_get_paths_for_accept_paths_as_parameter_checking_if_exists(
context,
find_module,
load_module,
exists):
u"get_paths_for also takes paths, and check if exists"
find_module.side_effect = ImportError('no module named /some/path')
exists.side_effect = lambda x: x == '/path/to/file.py'
expected_paths = context.runner.get_paths_for(
['/path/to/file.py'],
appending=['more', 'members'],
)
@that_with_context(prepare_stuff, and_cleanup_the_mess)
def test_run_without_labels_gets_the_installed_apps(context, nose_run):
u"ability to run tests without labels will look for INSTALLED_APPS"
context.runner.get_apps = mock.Mock()
context.runner.get_apps.return_value = ['app1', 'app_two']
context.runner.get_nose_argv = mock.Mock()
context.runner.get_nose_argv.return_value = ['i', 'am', 'the', 'argv']
context.runner.get_paths_for = mock.Mock()
context.runner.get_paths_for.return_value = [
'/path/to/app1/tests',
'/and/another/path/to/app_two/tests',
]
context.runner.setup_test_environment = mock.Mock()
@sure.that_with_context(setup)
def it_fails(context):
assert False, 'should fail with this exception'
@that_with_context(prepare_stuff, and_cleanup_the_mess)
def test_should_fetch_the_apps_names_thru_get_apps_method(context):
u"Nose.get_apps filters django builtin apps"
settings.INSTALLED_APPS = (
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'foo',
'bar',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
)
assert that(context.runner.get_apps()).equals((
'foo',
'bar',