Metadata-Version: 1.1
Name: unittest-sandbox
Version: 1.0.3
Summary: unittest_sandbox provides a @sandbox decorator which ensures unit test methods do not make any socket/web requests during test execution.
Home-page: https://github.com/mikeengland/unittest_sandbox
Author: Michael England
Author-email: UNKNOWN
License: Apache License Version 2.0
Description: unittest-sandbox
        ================
        
        unittest-sandbox provides a @sandbox decorator which ensures unit test
        methods do not make any socket/web requests during test execution. Note:
        This currently only works with Python 3.
        
        Installation
        ------------
        
        To install run: ``pip install unittest_sandbox``
        
        Example usage
        -------------
        
        .. code:: python
        
            from unittest import TestCase
        
            import requests
        
            from unittest_sandbox import InternetAccessBlockedException, sandbox
        
            # The @sandbox() decorator can be applied to methods individually like below
        
            class RequestTests(TestCase):
                def test_non_request_works(self):
                    self.assertEqual(1 + 1, 2)
        
                @sandbox()
                def test_web_request_raises_exception_when_sandbox_decorator_is_applied(self):
                    # If a web request is sent in a test method wrapped with the @sandbox decorator,
                    # an InternetAccessBlockedException will be raised.
        
                    with self.assertRaises(InternetAccessBlockedException):
                        requests.get('https://www.google.com')
        
            # The @sandbox() decorator can also be applied to the class as a whole. This is the same as decorating
            # all 'test_' methods with @sandbox()
        
            @sandbox()
            class RequestTests(TestCase):
                def test_non_request_works(self):
                    self.assertEqual(1 + 1, 2)
        
                def test_web_request_raises_exception_when_sandbox_decorator_is_applied(self):
                    # If a web request is sent in a test method wrapped with the @sandbox decorator,
                    # an InternetAccessBlockedException will be raised.
        
                    with self.assertRaises(InternetAccessBlockedException):
                        requests.get('https://www.google.com')
        
        
Keywords: unittest unittests testcase sandbox internet block decorator socket requests urllib
Platform: UNKNOWN
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Operating System :: POSIX
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
