예제 #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
파일: tests.py 프로젝트: athonlab/OpenHatch
def twill_teardown():
    twill.remove_wsgi_intercept('127.0.0.1', 8080)
예제 #23
0
파일: testutil.py 프로젝트: ctb/pony-build
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
파일: test-wsgi.py 프로젝트: zhou0/quixote
    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()