summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Szakmeister <john@szakmeister.net>2014-04-18 19:33:26 -0400
committerJohn Szakmeister <john@szakmeister.net>2014-04-19 10:22:44 -0400
commita0835939c02f2081351cb7219053d27d9224bca4 (patch)
tree370adda35ef36e8dda9782e6ec215db950fd0114
parent30d8af723c14dba9196faae397007f510eb02a76 (diff)
downloadnose-a0835939c02f2081351cb7219053d27d9224bca4.tar.gz
Add a few tests with raising string exceptions.
-rw-r--r--functional_tests/support/string-exception/test.py30
-rw-r--r--functional_tests/test_string_exception.py32
2 files changed, 62 insertions, 0 deletions
diff --git a/functional_tests/support/string-exception/test.py b/functional_tests/support/string-exception/test.py
new file mode 100644
index 0000000..7b63d9d
--- /dev/null
+++ b/functional_tests/support/string-exception/test.py
@@ -0,0 +1,30 @@
+import unittest
+import warnings
+
+warnings.filterwarnings('ignore', category=DeprecationWarning,
+ module='test')
+
+
+def test_string_exc():
+ raise "string exception"
+
+
+class TestStringExceptionInSetup(unittest.TestCase):
+ def setUp(self):
+ raise "string exception in setup"
+
+ def testNothing(self):
+ pass
+
+
+class TestStringExceptionInTeardown(unittest.TestCase):
+ def tearDown(self):
+ raise "string exception in teardown"
+
+ def testNothing(self):
+ pass
+
+
+class TestStringExceptionInClass(unittest.TestCase):
+ def testStringExc(self):
+ raise "string exception in test"
diff --git a/functional_tests/test_string_exception.py b/functional_tests/test_string_exception.py
new file mode 100644
index 0000000..396c92a
--- /dev/null
+++ b/functional_tests/test_string_exception.py
@@ -0,0 +1,32 @@
+import os
+import sys
+import unittest
+
+from nose.plugins import PluginTester
+from nose.plugins.builtin import Deprecated, Skip
+from nose.plugins.skip import SkipTest
+
+
+support = os.path.join(os.path.dirname(__file__), 'support')
+
+
+class TestStringException(PluginTester, unittest.TestCase):
+ activate = '-v'
+ plugins = [Deprecated(), Skip()]
+ args = []
+ suitepath = os.path.join(support, 'string-exception')
+
+ def test_string_exception_works(self):
+ if sys.version_info >= (2, 6):
+ raise SkipTest("String exceptions are not supported in this "
+ "version of Python")
+
+ print
+ print '!' * 70
+ print str(self.output)
+ print '!' * 70
+ print
+ assert 'raise "string exception"' in str(self.output)
+ assert 'raise "string exception in setup"' in str(self.output)
+ assert 'raise "string exception in teardown"' in str(self.output)
+ assert 'raise "string exception in test"' in str(self.output)