__author__ = "John Kirkham <kirkhamj@janelia.hhmi.org>"
__date__ = "$May 18, 2015 22:08:21 EDT$"


import os
import shutil
import tempfile
import time

from splauncher.core import main


class TestCore(object):
    def setup(self):
        self.cwd = os.getcwd()
        self.tempdir = ""
        self.tempdir = tempfile.mkdtemp()
        os.chdir(self.tempdir)

    def teardown(self):
        os.chdir(self.cwd)
        shutil.rmtree(self.tempdir)
        self.tempdir = ""
        self.cwd = ""

    def test_main_0(self):
        main("echo", "output")

        time.sleep(50.0)

        filenames = []
        for each_filename in os.listdir(self.tempdir):
            filenames.append(os.path.join(self.tempdir, each_filename))

        assert ".err" in filenames[0]
        assert ".out" in filenames[1]

        with open(filenames[0], "r") as f:
            assert f.read() == ""

        with open(filenames[1], "r") as f:
            assert f.read().strip() == "output"

    def test_main_1(self):
        main("echo", "error", "1>&2")

        time.sleep(50.0)

        filenames = []
        for each_filename in os.listdir(self.tempdir):
            filenames.append(os.path.join(self.tempdir, each_filename))

        assert ".err" in filenames[0]
        assert ".out" in filenames[1]

        with open(filenames[0], "r") as f:
            assert f.read().strip() == "error"

        with open(filenames[1], "r") as f:
            assert f.read() == ""

@@ -1,8 +1,48 @@
+from __future__ import print_function%0A%0A%0A
 __author
@@ -892,38 +892,35 @@
  f:%0A            
-assert
+s =
  f.read() == %22%22%0A
@@ -908,24 +908,74 @@
 s = f.read()
+.strip()%0A            print(s)%0A            assert s
  == %22%22%0A%0A    
@@ -1017,38 +1017,35 @@
  f:%0A            
-assert
+s =
  f.read().strip(
@@ -1041,24 +1041,66 @@
 ad().strip()
+%0A            print(s)%0A            assert s
  == %22output%22
@@ -1468,38 +1468,35 @@
  f:%0A            
-assert
+s =
  f.read().strip(
@@ -1496,16 +1496,58 @@
 .strip()
+%0A            print(s)%0A            assert s
  == %22err
@@ -1606,22 +1606,19 @@
         
-assert
+s =
  f.read(
@@ -1618,15 +1618,65 @@
 f.read()
+.strip()%0A            print(s)%0A            assert s
  == %22%22%0A

Print file content.