Beispiel #1
0
    def test_get_spam_checker(self):
        try:
            with warnings.catch_warnings(record=True) as w:
                self.assertEquals(get_spam_checker('mymodule.myclass'), None)
                self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
                self.assertEquals(
                    str(w[-1].message),
                    'mymodule.myclass backend cannot be imported')
        except AttributeError:
            # Fail under Python2.5, because of'warnings.catch_warnings'
            pass

        try:
            with warnings.catch_warnings(record=True) as w:
                self.assertEquals(
                    get_spam_checker('zinnia.tests.custom_spam_checker'), None)
                self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
                self.assertEquals(str(w[-1].message),
                                  'This backend only exists for testing')
        except AttributeError:
            # Fail under Python2.5, because of'warnings.catch_warnings'
            pass

        self.assertEquals(
            get_spam_checker('zinnia.spam_checker.backends.all_is_spam'),
            backend)
    def test_get_spam_checker(self):
        try:
            with warnings.catch_warnings(record=True) as w:
                self.assertEquals(get_spam_checker('mymodule.myclass'), None)
                self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
                self.assertEquals(
                    str(w[-1].message),
                    'mymodule.myclass backend cannot be imported')
        except AttributeError:
            # Fail under Python2.5, because of'warnings.catch_warnings'
            pass

        try:
            with warnings.catch_warnings(record=True) as w:
                self.assertEquals(
                    get_spam_checker('zinnia.tests.custom_spam_checker'), None)
                self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
                self.assertEquals(
                    str(w[-1].message),
                    'This backend only exists for testing')
        except AttributeError:
            # Fail under Python2.5, because of'warnings.catch_warnings'
            pass

        self.assertEquals(
            get_spam_checker('zinnia.spam_checker.backends.all_is_spam'),
            backend)
Beispiel #3
0
    def test_get_spam_checker(self):
        with warnings.catch_warnings(record=True) as w:
            self.assertEquals(get_spam_checker('mymodule.myclass'), None)
            self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
            self.assertEquals(str(w[-1].message),
                              'mymodule.myclass backend cannot be imported')

        with warnings.catch_warnings(record=True) as w:
            self.assertEquals(
                get_spam_checker('zinnia.tests.custom_spam_checker'), None)
            self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
            self.assertEquals(str(w[-1].message),
                              'This backend only exists for testing')

        self.assertEquals(
            get_spam_checker('zinnia.spam_checker.backends.all_is_spam'),
            backend)
Beispiel #4
0
    def test_get_spam_checker(self):
        with warnings.catch_warnings(record=True) as w:
            self.assertEquals(get_spam_checker('mymodule.myclass'), None)
            self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
            self.assertEquals(
                str(w[-1].message),
                'mymodule.myclass backend cannot be imported')

        with warnings.catch_warnings(record=True) as w:
            self.assertEquals(
                get_spam_checker('zinnia.tests.custom_spam_checker'), None)
            self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
            self.assertEquals(
                str(w[-1].message),
                'This backend only exists for testing')

        self.assertEquals(
            get_spam_checker('zinnia.spam_checker.backends.all_is_spam'),
            backend)
    def test_get_spam_checker(self):
        with warnings.catch_warnings(record=True) as w:
            #Without this, in python 3, depending on the flags passed in
            #on the command line, you might not get the warnings
            warnings.simplefilter("always")
            self.assertEqual(get_spam_checker('mymodule.myclass'), None)
            self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
            self.assertEqual(str(w[-1].message),
                             'mymodule.myclass backend cannot be imported')

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            self.assertEqual(
                get_spam_checker('zinnia.tests.custom_spam_checker'), None)
            self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
            self.assertEqual(str(w[-1].message),
                             'This backend only exists for testing')

        self.assertEqual(
            get_spam_checker('zinnia.spam_checker.backends.all_is_spam'),
            backend)
    def test_get_spam_checker(self):
        with warnings.catch_warnings(record=True) as w:
            #Without this, in python 3, depending on the flags passed in
            #on the command line, you might not get the warnings
            warnings.simplefilter("always")
            self.assertEqual(get_spam_checker('mymodule.myclass'), None)
            self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
            self.assertEqual(
                str(w[-1].message),
                'mymodule.myclass backend cannot be imported')

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            self.assertEqual(
                get_spam_checker('zinnia.tests.custom_spam_checker'), None)
            self.assertTrue(issubclass(w[-1].category, RuntimeWarning))
            self.assertEqual(
                str(w[-1].message),
                'This backend only exists for testing')

        self.assertEqual(
            get_spam_checker('zinnia.spam_checker.backends.all_is_spam'),
            backend)