OXIESEC PANEL
- Current Dir:
/
/
usr
/
lib
/
python3
/
dist-packages
/
hyperlink
/
test
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
10/21/2019 03:49:51 PM
rwxr-xr-x
📄
__init__.py
0 bytes
02/14/2017 06:45:31 PM
rw-r--r--
📁
__pycache__
-
10/21/2019 03:49:51 PM
rwxr-xr-x
📄
common.py
2.06 KB
06/30/2017 05:17:52 AM
rw-r--r--
📄
test_common.py
3.32 KB
06/30/2017 05:17:52 AM
rw-r--r--
📄
test_scheme_registration.py
2.27 KB
06/30/2017 05:17:52 AM
rw-r--r--
📄
test_url.py
43.45 KB
08/19/2017 07:24:15 AM
rw-r--r--
Editing: test_common.py
Close
""" Tests for hyperlink.test.common """ from unittest import TestCase from .common import HyperlinkTestCase class _ExpectedException(Exception): """An exception used to test HyperlinkTestCase.assertRaises. """ class _UnexpectedException(Exception): """An exception used to test HyperlinkTestCase.assertRaises. """ class TestHyperlink(TestCase): """Tests for HyperlinkTestCase""" def setUp(self): self.hyperlink_test = HyperlinkTestCase("run") def test_assertRaisesWithCallable(self): """HyperlinkTestCase.assertRaises does not raise an AssertionError when given a callable that, when called with the provided arguments, raises the expected exception. """ called_with = [] def raisesExpected(*args, **kwargs): called_with.append((args, kwargs)) raise _ExpectedException self.hyperlink_test.assertRaises(_ExpectedException, raisesExpected, 1, keyword=True) self.assertEqual(called_with, [((1,), {"keyword": True})]) def test_assertRaisesWithCallableUnexpectedException(self): """When given a callable that raises an unexpected exception, HyperlinkTestCase.assertRaises raises that exception. """ def doesNotRaiseExpected(*args, **kwargs): raise _UnexpectedException try: self.hyperlink_test.assertRaises(_ExpectedException, doesNotRaiseExpected) except _UnexpectedException: pass def test_assertRaisesWithCallableDoesNotRaise(self): """HyperlinkTestCase.assertRaises raises an AssertionError when given a callable that, when called, does not raise any exception. """ def doesNotRaise(*args, **kwargs): return True try: self.hyperlink_test.assertRaises(_ExpectedException, doesNotRaise) except AssertionError: pass def test_assertRaisesContextManager(self): """HyperlinkTestCase.assertRaises does not raise an AssertionError when used as a context manager with a suite that raises the expected exception. The context manager stores the exception instance under its `exception` instance variable. """ with self.hyperlink_test.assertRaises(_ExpectedException) as cm: raise _ExpectedException self.assertTrue(isinstance(cm.exception, _ExpectedException)) def test_assertRaisesContextManagerUnexpectedException(self): """When used as a context manager with a block that raises an unexpected exception, HyperlinkTestCase.assertRaises raises that unexpected exception. """ try: with self.hyperlink_test.assertRaises(_ExpectedException): raise _UnexpectedException except _UnexpectedException: pass def test_assertRaisesContextManagerDoesNotRaise(self): """HyperlinkTestcase.assertRaises raises an AssertionError when used as a context manager with a block that does not raise any exception. """ try: with self.hyperlink_test.assertRaises(_ExpectedException): pass except AssertionError: pass