import os
import requests
import signal
import subprocess
import unittest
import time


pearl_exe = 'build/pearl'
pearl_opts = '-P test_store'
pearl_url = 'http://127.0.0.1:8888'


class TestDatabase(unittest.TestCase):

    def setUp(self):
        drop = subprocess.Popen('{0} drop {1}'.format(pearl_exe, pearl_opts), shell=True, stderr=subprocess.STDOUT)
        drop.wait()
        self.pearl_process = subprocess.Popen('{0} {1}'.format(pearl_exe, pearl_opts), shell=True, stderr=subprocess.STDOUT)
        time.sleep(0.1)

    def tearDown(self):
        # self.pearl_process.kill()
        os.kill(self.pearl_process.pid, signal.SIGKILL)

    def test_put(self):
        target_url = '{0}/x/'.format(pearl_url)

        r = requests.put(target_url, 'xxx')
        self.assertEqual(r.status_code, 200)

        r = requests.get(target_url)
        self.assertEqual(r.status_code, 200)
        self.assertEqual(r.content, 'xxx')

    def test_get_non_existent_results_in_404(self):
        target_url = '{0}/x/'.format(pearl_url)
        r = requests.get(target_url)
        self.assertEqual(r.status_code, 404)
        self.assertEqual(r.content, '')


if __name__ == '__main__':
    unittest.main()

@@ -111,37 +111,8 @@
 rl'%0A
-pearl_opts = '-P test_store'%0A
 pear
@@ -197,18 +197,26 @@
 def 
-setUp(self
+drop_db(self, name
 ):%0A 
@@ -256,16 +256,19 @@
 0%7D drop 
+-P 
 %7B1%7D'.for
@@ -278,34 +278,28 @@
 (pearl_exe, 
-pearl_opts
+name
 ), shell=Tru
@@ -346,16 +346,47 @@
 p.wait()
+%0A%0A    def start_db(self, name):
 %0A       
@@ -428,16 +428,19 @@
 pen('%7B0%7D
+ -P
  %7B1%7D'.fo
@@ -459,18 +459,12 @@
 xe, 
-pearl_opts
+name
 ), s
@@ -525,16 +525,109 @@
 p(0.1)%0A%0A
+    def setUp(self):%0A        self.drop_db('test_store')%0A        self.start_db('test_store')%0A%0A
     def 

Clean up tests