Пример #1
0
    def _post_teardown(self):

        twill.remove_wsgi_intercept(self.twill_host, self.twill_port)

        twill.commands.reset_output()

        super(TwillTestCase, self)._post_teardown()
Пример #2
0
 def tearDown(self):
     import twill
     import twill.commands
     twill.commands.reset_browser()
     twill.remove_wsgi_intercept('localhost', 6543)
     twill.set_output(None)
     testing.tearDown()
Пример #3
0
    def test_refeed(self):
        """
        Try refeeding the content into the app.
        """
        
        recorder = scotch.recorder.Recorder(simple_app.iter_app)

        # first, record.
        twill.add_wsgi_intercept('localhost', 80, lambda: recorder)
        try:
            twill.commands.go('http://localhost:80/')
            output1 = twill.commands.show()
            assert simple_app.success()
        finally:
            simple_app.reset()
            twill.remove_wsgi_intercept('localhost', 80)

        # get the recorded bit.
        assert len(recorder.record_holder) == 1
        record = recorder.record_holder[0]

        try:
            response = record.refeed(simple_app.iter_app)
            assert simple_app.success()
            output2 = response.get_output()
            assert output1 == output2
        finally:
            simple_app.reset()
Пример #4
0
 def tearDown(self):
     # If you get an error on one of these lines,
     # maybe you didn't run base.TwillTests.setUp?
     settings.DEBUG_PROPAGATE_EXCEPTIONS = self.old_dbe
     twill.remove_wsgi_intercept('127.0.0.1', 8080)
     tc.reset_browser()
     django.core.cache.cache.get = self.real_get
Пример #5
0
def teardown(host=None, port=None):
    """Remove an installed WSGI hook for ``host`` and ```port``.

    If no host or port is passed, the default values will be assumed.
    If no hook is installed for the defaults, and both the host and
    port are missing, the last hook installed will be removed.

    Returns True if a hook was removed, otherwise False.
    """

    both_missing = not host and not port
    host = host or DEFAULT_HOST
    port = port or DEFAULT_PORT
    key = (host, port)

    key_to_delete = None
    if key in INSTALLED:
        key_to_delete = key
    if not key in INSTALLED and both_missing and len(INSTALLED) > 0:
        host, port = key_to_delete = INSTALLED.keys()[-1]

    if key_to_delete:
        _, old_propagate = INSTALLED[key_to_delete]
        del INSTALLED[key_to_delete]
        result = True
        if old_propagate is not None:
            settings.DEBUG_PROPAGATE_EXCEPTIONS = old_propagate
    else:
        result = False

    # note that our return value is just a guess according to our
    # own records, we pass the request on to twill in any case
    twill.remove_wsgi_intercept(host, port)
    return result
Пример #6
0
    def test_multirefeed(self):
        """
        Test playback of multiple requests.
        """
        recorder = scotch.recorder.Recorder(simple_app.post_app)

        # first, record.
        twill.add_wsgi_intercept('localhost', 80, lambda: recorder)
        try:
            twill.commands.go('http://localhost:80/')
            assert simple_app.success()
            simple_app.reset()
            
            twill.commands.fv('1', 'test', 'howdy world')
            twill.commands.submit()
            twill.commands.find("VALUE WAS: howdy world")
            assert simple_app.success()
        finally:
            simple_app.reset()
            twill.remove_wsgi_intercept('localhost', 80)

        # check the length of the recorded bit.
        assert len(recorder.record_holder) == 2

        # play it all back.
        try:
            assert not simple_app.success()
            for record in recorder.record_holder:
                record.refeed(simple_app.post_app)
            assert simple_app.success()
        finally:
            simple_app.reset()
Пример #7
0
def teardown(host=None, port=None):
    """Remove an installed WSGI hook for ``host`` and ```port``.

    If no host or port is passed, the default values will be assumed.
    If no hook is installed for the defaults, and both the host and
    port are missing, the last hook installed will be removed.

    Returns True if a hook was removed, otherwise False.
    """

    both_missing = not host and not port
    host = host or DEFAULT_HOST
    port = port or DEFAULT_PORT
    key = (host, port)

    key_to_delete = None
    if key in INSTALLED:
        key_to_delete = key
    if not key in INSTALLED and both_missing and len(INSTALLED) > 0:
        host, port = key_to_delete = INSTALLED.keys()[-1]

    if key_to_delete:
        _, old_propagate = INSTALLED[key_to_delete]
        del INSTALLED[key_to_delete]
        result = True
        if old_propagate is not None:
            settings.DEBUG_PROPAGATE_EXCEPTIONS = old_propagate
    else:
        result = False

    # note that our return value is just a guess according to our
    # own records, we pass the request on to twill in any case
    twill.remove_wsgi_intercept(host, port)
    return result
Пример #8
0
    def _post_teardown(self):

        twill.remove_wsgi_intercept(self.twill_host, 
                                    self.twill_port)

        twill.commands.reset_output()
        
        super(TwillTestCase, self)._post_teardown()
Пример #9
0
def test_iter_stuff():
    twill.add_wsgi_intercept('localhost', 80, iterator_app)
    print 'go'
    twill.commands.go('http://localhost:80/')
    print 'find'
    twill.commands.show()
    twill.commands.find("Hello, world")
    twill.commands.notfind("Hello, worldHello, world")
    print 'remove'
    twill.remove_wsgi_intercept('localhost', 80)
Пример #10
0
def test_iter_stuff():
    twill.add_wsgi_intercept('localhost', 80, iterator_app)
    print 'go'
    twill.commands.go('http://localhost:80/')
    print 'find'
    twill.commands.show()
    twill.commands.find("Hello, world")
    twill.commands.notfind("Hello, worldHello, world")
    print 'remove'
    twill.remove_wsgi_intercept('localhost', 80)
Пример #11
0
    def tearDown(self):
        # remove intercept
        twill.remove_wsgi_intercept('localhost', 6543)

        test_path =  os.path.abspath(os.path.dirname(__file__))
        fixtures = os.path.join(test_path, 'fixtures')
        for to_delete in [fname for fname in os.listdir(fixtures)
                          if fname.startswith('Data.fs') or fname in
                          ['blobs', 'mail_queue']]:
            _rm(os.path.join(fixtures, to_delete))
Пример #12
0
 def test_basic(self):
     """
     Test the basic setup (iter_app, twill, and wsgi_intercept).
     """
     
     twill.add_wsgi_intercept('localhost', 80, lambda:simple_app.iter_app)
     try:
         twill.commands.go('http://localhost:80/')
         twill.commands.find('WSGI intercept')
         assert simple_app.success()
     finally:
         simple_app.reset()
         twill.remove_wsgi_intercept('localhost', 80)
Пример #13
0
def test_intercept():
    global _app_was_hit
    _app_was_hit = False

    twill.add_wsgi_intercept('localhost', 80, lambda: wsgi_lint(simple_app))
    assert not _app_was_hit
    print 'go'
    twill.commands.go('http://localhost:80/')
    twill.commands.show()
    print 'find'
    twill.commands.find("WSGI intercept successful")
    assert _app_was_hit
    print 'remove'
    twill.remove_wsgi_intercept('localhost', 80)
Пример #14
0
def test_intercept():
    global _app_was_hit
    _app_was_hit = False

    twill.add_wsgi_intercept('localhost', 80, lambda: wsgi_lint(simple_app))
    assert not _app_was_hit
    print 'go'
    twill.commands.go('http://localhost:80/')
    twill.commands.show()
    print 'find'
    twill.commands.find("WSGI intercept successful")
    assert _app_was_hit
    print 'remove'
    twill.remove_wsgi_intercept('localhost', 80)
Пример #15
0
    def test_passthru(self):
        """
        Make sure that the recorder actually calls the app correctly, etc.
        """
        
        recorder = scotch.recorder.Recorder(simple_app.iter_app)

        twill.add_wsgi_intercept('localhost', 80, lambda: recorder)
        try:
            twill.commands.go('http://localhost:80/')
            twill.commands.find('WSGI intercept')
            assert simple_app.success()
        finally:
            simple_app.reset()
            twill.remove_wsgi_intercept('localhost', 80)
Пример #16
0
 def test_basic(self):
     """
     Test the basic setup (post_app, twill, and wsgi_intercept).
     """
     
     twill.add_wsgi_intercept('localhost', 80, lambda:simple_app.post_app)
     try:
         twill.commands.go('http://localhost:80/')
         assert simple_app.success()
         
         twill.commands.fv('1', 'test', 'howdy world')
         twill.commands.submit()
         twill.commands.find("VALUE WAS: howdy world")
     finally:
         simple_app.reset()
         twill.remove_wsgi_intercept('localhost', 80)
Пример #17
0
    def test_passthru(self):
        """
        Make sure that the recorder actually calls the app correctly, etc.
        """
        
        recorder = scotch.recorder.Recorder(simple_app.post_app)

        twill.add_wsgi_intercept('localhost', 80, lambda: recorder)
        try:
            twill.commands.go('http://localhost:80/')
            assert simple_app.success()
            
            twill.commands.fv('1', 'test', 'howdy world')
            twill.commands.submit()
            twill.commands.find("VALUE WAS: howdy world")
        finally:
            simple_app.reset()
            twill.remove_wsgi_intercept('localhost', 80)
Пример #18
0
    def test_multirecord(self):
        """
        Test recording of multiple requests.
        """
        recorder = scotch.recorder.Recorder(simple_app.iter_app)

        # first, record.
        twill.add_wsgi_intercept('localhost', 80, lambda: recorder)
        try:
            twill.commands.go('http://localhost:80/')
            assert simple_app.success()
            simple_app.reset()
            
            twill.commands.go('./')
            assert simple_app.success()
        finally:
            simple_app.reset()
            twill.remove_wsgi_intercept('localhost', 80)

        # check the length of recorded bit.
        assert len(recorder.record_holder) == 2
Пример #19
0
def test_wrapper_intercept():
    """
    This tests a tricky wsgi_intercept interaction between the 'write' fn
    passed back from the start_response function in WSGI, and the generator
    data yielded from the initial app call.

    See wsgi_intercept.py, section containing 'generator_data', for more
    info.
    """
    global _app_was_hit
    _app_was_hit = False

    wrap_app = wrapper_app(write_app)

    twill.add_wsgi_intercept('localhost', 80, lambda: wsgi_lint(wrap_app))
    assert not _app_was_hit
    print 'go'
    twill.commands.go('http://localhost:80/')
    print 'find'
    twill.commands.find("WSGI intercept successful")
    assert _app_was_hit
    print 'remove'
    twill.remove_wsgi_intercept('localhost', 80)
Пример #20
0
def test_wrapper_intercept():
    """
    This tests a tricky wsgi_intercept interaction between the 'write' fn
    passed back from the start_response function in WSGI, and the generator
    data yielded from the initial app call.

    See wsgi_intercept.py, section containing 'generator_data', for more
    info.
    """
    global _app_was_hit
    _app_was_hit = False

    wrap_app = wrapper_app(write_app)

    twill.add_wsgi_intercept('localhost', 80, lambda: wsgi_lint(wrap_app))
    assert not _app_was_hit
    print 'go'
    twill.commands.go('http://localhost:80/')
    print 'find'
    twill.commands.find("WSGI intercept successful")
    assert _app_was_hit
    print 'remove'
    twill.remove_wsgi_intercept('localhost', 80)
Пример #21
0
def kill_server_wsgi_intercept():
    quixote.publish._publisher = None
    twill.remove_wsgi_intercept(_server_host, _server_port)
Пример #22
0
def twill_teardown():
    twill.remove_wsgi_intercept('127.0.0.1', 8080)
Пример #23
0
def kill_server_wsgi_intercept():
    quixote.publish._publisher = None
    twill.remove_wsgi_intercept(_server_host, _server_port)
Пример #24
0
 def _post_teardown(self):
 
     self._urlconf_teardown()
     self._fixture_teardown()
     remove_wsgi_intercept(self.domain, self.port)
Пример #25
0
 def tearDown(self):
     twill.remove_wsgi_intercept(self.HOST, self.PORT)
Пример #26
0
 def tearDown(self):
     self.browser.go(reverse_for_twill('admin:logout'))
     twill.remove_wsgi_intercept(TWILL_TEST_HOST, 80)
     signals.request_finished.connect(close_connection)
     settings.DEBUG_PROPAGATE_EXCEPTIONS = self.old_propagate
Пример #27
0
    def __exit__(self, exc_type, exc_value, tb):
        twill.remove_wsgi_intercept(self.host, self.port)

        twill.commands.reset_output()
Пример #28
0
 def teardown(self):
     """ clear test data """
     super(TwillMock, self).teardown()
     User.objects.all().delete()
     remove_wsgi_intercept(IP, PORT)
Пример #29
0
    def teardown(self):
        twill.remove_wsgi_intercept('localhost', 80)

        quixote.cleanup()
Пример #30
0
    def teardown(self):
        twill.remove_wsgi_intercept("localhost", 80)

        quixote.cleanup()
Пример #31
0
 def tearDown(self):
     twill.remove_wsgi_intercept('localhost', 8080)
     cherrypy.server.stop()
Пример #32
0
 def remove_twill(self):
     self.restore_twill_output()
     twill.remove_wsgi_intercept('localhost', 80)
Пример #33
0
 def cleanup():
     twill.remove_wsgi_intercept("localhost", 8080)
     twill.remove_wsgi_intercept("systemexit.de", 80)
     twill.remove_wsgi_intercept("pypi.python.org", 80)
     if loadapp:
         twill.remove_wsgi_intercept("nonroot", 80)
Пример #34
0
 def tearDown(self):
     super(NaayaFunctionalTestCase, self).tearDown()
     self.restore_twill_output()
     twill.remove_wsgi_intercept('localhost', 80)
Пример #35
0
    def __exit__(self, exc_type, exc_value, tb):
        twill.remove_wsgi_intercept(self.host, 
                                    self.port)

        twill.commands.reset_output()
Пример #36
0
def twill_teardown():
    twill.remove_wsgi_intercept('127.0.0.1', 8080)
    tc.reset_browser()
Пример #37
0
 def cleanup():
     twill.remove_wsgi_intercept("localhost", 8080)
     twill.remove_wsgi_intercept("systemexit.de", 80)
     twill.remove_wsgi_intercept("pypi.python.org", 80)
     if loadapp:
         twill.remove_wsgi_intercept("nonroot", 80)
Пример #38
0
 def twill_teardown(self):
     twill.remove_wsgi_intercept('127.0.0.1', TEST_PORT)
Пример #39
0
def after_all(context):
    twill.remove_wsgi_intercept("127.0.0.1","8000")
    twill.commands.reset_output()
Пример #40
0
def twill_teardown():
    twill.remove_wsgi_intercept('127.0.0.1', 8080)
    tc.reset_browser()
Пример #41
0
 def remove_twill(self):
     self.restore_twill_output()
     twill.remove_wsgi_intercept('localhost', 80)
Пример #42
0
 def tearDown(self):
     twill.remove_wsgi_intercept(self.HOST, self.PORT)
Пример #43
0
def twill_teardown():
    twill.remove_wsgi_intercept('127.0.0.1', 8080)
Пример #44
0
def teardown(module):
    twill.remove_wsgi_intercept('localhost', 4444)
    cpy.engine.stop()