File: test_settings.py

package info (click to toggle)
flask-api 0.6.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 316 kB
  • ctags: 329
  • sloc: python: 1,284; sh: 21; makefile: 10
file content (21 lines) | stat: -rw-r--r-- 780 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# coding: utf8
from __future__ import unicode_literals
from flask_api.settings import APISettings
import unittest


class SettingsTests(unittest.TestCase):
    def test_bad_import(self):
        settings = APISettings({'DEFAULT_PARSERS': 'foobarz.FailedImport'})
        with self.assertRaises(ImportError) as context:
            settings.DEFAULT_PARSERS
        msg = str(context.exception)
        excepted_py2 = (
            "Could not import 'foobarz.FailedImport' for API setting "
            "'DEFAULT_PARSERS'. No module named foobarz."
        )
        excepted_py3 = (
            "Could not import 'foobarz.FailedImport' for API setting "
            "'DEFAULT_PARSERS'. No module named 'foobarz'."
        )
        self.assertIn(msg, (excepted_py2, excepted_py3))