def test_testsuite_minimal(): with runner.isolated_filesystem(): runner.invoke(['new', 'myproject', '--layout', 'minimal']) os.chdir('myproject') setup_pythonpath() result = runner.invoke(['test']) assert '2 passed' in result.output assert result.exit_code == 0
def test_missing_app_module(): with runner.isolated_filesystem(): runner.invoke(['new', 'myproject', '--layout', 'minimal']) os.chdir('myproject') setup_pythonpath() os.remove('app.py') result = runner.invoke(['run']) assert isinstance(result.exception, exceptions.ConfigurationError) assert result.exit_code != 0
def test_misconfigured_app_module(): with runner.isolated_filesystem(): runner.invoke(['new', 'myproject', '--template', 'minimal']) os.chdir('myproject') setup_pythonpath() with open('app.py', 'w') as app_module: app_module.write('123\n') result = runner.invoke(['run']) assert isinstance(result.exception, exceptions.ConfigurationError) assert result.exit_code != 0
def test_testsuite_standard(): with runner.isolated_filesystem(): runner.invoke(['new', 'myproject']) os.chdir('myproject') setup_pythonpath() result = runner.invoke(['test']) assert '2 passed' in result.output assert result.exit_code == 0 # Add a failing test case. failing_test_module = os.path.join('tests', 'test_failure.py') with open(failing_test_module, 'w') as test_module: test_module.write('def test_failure():\n raise Exception()\n') result = runner.invoke(['test']) assert '1 failed, 2 passed' in result.output assert result.exit_code != 0