Пример #1
0
        def test_project_pecan_serve_command(self):
            # Start the server
            proc = subprocess.Popen([
                os.path.join(self.bin, 'pecan'),
                'serve',
                'testing123/config.py'
            ])

            try:
                self.poll(proc)
                retries = 30
                while True:
                    retries -= 1
                    if retries < 0:  # pragma: nocover
                        raise RuntimeError(
                            "The HTTP server has not replied within 3 seconds."
                        )
                    try:
                        # ...and that it's serving (valid) content...
                        resp = urlopen('http://localhost:8080/')
                        assert resp.getcode() == 200
                        assert 'This is a sample Pecan project.' in \
                            resp.read().decode()
                    except URLError:
                        pass
                    else:
                        break
                    time.sleep(.1)
            finally:
                proc.terminate()
Пример #2
0
        def test_project_pecan_serve_command(self):
            # Start the server
            proc = subprocess.Popen([
                os.path.join(self.bin, 'pecan'), 'serve',
                'testing123/config.py'
            ])

            try:
                self.poll(proc)
                retries = 30
                while True:
                    retries -= 1
                    if retries < 0:  # pragma: nocover
                        raise RuntimeError(
                            "The HTTP server has not replied within 3 seconds."
                        )
                    try:
                        # ...and that it's serving (valid) content...
                        resp = urlopen('http://localhost:8080/')
                        assert resp.getcode()
                        assert len(resp.read().decode())
                    except URLError:
                        pass
                    else:
                        break
                    time.sleep(.1)
            finally:
                proc.terminate()
Пример #3
0
 def poll_http(self, name, proc, port):
     try:
         self.poll(proc)
         retries = 30
         while True:
             retries -= 1
             if retries < 0:  # pragma: nocover
                 raise RuntimeError(
                     "The %s server has not replied within"
                     " 3 seconds." % name)
             try:
                 # ...and that it's serving (valid) content...
                 resp = urlopen('http://localhost:%d/' % port)
                 assert resp.getcode()
                 assert len(resp.read().decode())
             except URLError:
                 pass
             else:
                 break
             time.sleep(.1)
     finally:
         proc.terminate()
Пример #4
0
 def poll_http(self, name, proc, port):
     try:
         self.poll(proc)
         retries = 30
         while True:
             retries -= 1
             if retries < 0:  # pragma: nocover
                 raise RuntimeError(
                     "The %s server has not replied within"
                     " 3 seconds." % name
                 )
             try:
                 # ...and that it's serving (valid) content...
                 resp = urlopen('http://localhost:%d/' % port)
                 assert resp.getcode()
                 assert len(resp.read().decode())
             except URLError:
                 pass
             else:
                 break
             time.sleep(.1)
     finally:
         proc.terminate()
Пример #5
0
 def poll_gunicorn(self, proc, port):
     try:
         self.poll(proc)
         retries = 30
         while True:
             retries -= 1
             if retries < 0:  # pragma: nocover
                 raise RuntimeError(
                     "The gunicorn server has not replied within"
                     " 3 seconds."
                 )
             try:
                 # ...and that it's serving (valid) content...
                 resp = urlopen('http://localhost:%d/' % port)
                 assert resp.getcode() == 200
                 assert 'This is a sample Pecan project.' in \
                     resp.read().decode()
             except URLError:
                 pass
             else:
                 break
             time.sleep(.1)
     finally:
         proc.terminate()