# Path: test/simple.py
# class Base(unittest.TestCase):
#     config = CONFIG
# 
#     def setUp(self):
#         self.do_init()
#         time.sleep(START_TIMEOUT)
# 
#     def do_init(self):
#         self.proc = subprocess.Popen([ZEROGW_BINARY, '-c', self.config])
#         self.addCleanup(stop_process, self.proc)
# 
#     def http(self, host='localhost'):
#         conn = http.HTTPConnection(host, timeout=1.0)
#         conn.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
#         for i in range(100):
#             try:
#                 conn.sock.connect(HTTP_ADDR)
#             except socket.error:
#                 time.sleep(0.1)
#                 continue
#             else:
#                 break
#         else:
#             raise RuntimeError("Can't connect to zerogw")
#         return conn
# 
#     def websock(self, **kw):
#         return CheckingWebsock(self, **kw)


import unittest
from .simple import Base


class CrashTest(Base):
    config = 'test/crash1.yaml'

    def testBadRequest(self):
        conn = self.http()
        conn.request('GET', '/')
        resp = conn.getresponse()
        self.assertTrue(b'Not Found' in resp.read())
        conn.close()

    def testGoodRequest(self):
        conn = self.http('hello')
        conn.request('GET', '/')
        resp = conn.getresponse()
        self.assertTrue(b'Not Found' not in resp.read())
        conn.close()



# Path: test/simple.py
# class Base(unittest.TestCase):
#     config = CONFIG
# 
#     def setUp(self):
#         self.do_init()
#         time.sleep(START_TIMEOUT)
# 
#     def do_init(self):
#         self.proc = subprocess.Popen([ZEROGW_BINARY, '-c', self.config])
#         self.addCleanup(stop_process, self.proc)
# 
#     def http(self, host='localhost'):
#         conn = http.HTTPConnection(host, timeout=1.0)
#         conn.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
#         for i in range(100):
#             try:
#                 conn.sock.connect(HTTP_ADDR)
#             except socket.error:
#                 time.sleep(0.1)
#                 continue
#             else:
#                 break
#         else:
#             raise RuntimeError("Can't connect to zerogw")
#         return conn
# 
#     def websock(self, **kw):
#         return CheckingWebsock(self, **kw)


# Path: test/crash.py
import unittest
from .simple import Base



class CrashTest(Base):
    config = 'test/crash1.yaml'

    def testBadRequest(self):
        conn = self.http()
        conn.request('GET', '/')
        resp = conn.getresponse()
        self.assertTrue(b'Not Found' in resp.read())
        conn.close()

    def testGoodRequest(self):
        conn = self.http('hello')
        conn.request('GET', '/')
        resp = conn.getresponse()
        self.assertTrue(b'Not Found' not in resp.read())
        conn.close()



class CrashTest2(Base):