write tests for test_case
diff --git a/typ/host.py b/typ/host.py
index 038054d..43672e9 100644
--- a/typ/host.py
+++ b/typ/host.py
@@ -42,8 +42,15 @@
             sys.path.append(absolute_path)
 
     def call(self, argv, stdin=None, env=None):
+        if stdin:
+            stdin_pipe = subprocess.PIPE
+        else:
+            stdin_pipe = None
         proc = subprocess.Popen(argv, stdout=subprocess.PIPE,
-                                stderr=subprocess.PIPE, stdin=stdin, env=env)
+                                stderr=subprocess.PIPE, stdin=stdin_pipe,
+                                env=env)
+        if stdin_pipe:
+            proc.stdin.write(stdin)
         stdout, stderr = proc.communicate()
         return proc.returncode, stdout, stderr
 
diff --git a/typ/test_case.py b/typ/test_case.py
index 4ef73fe..fc878b6 100644
--- a/typ/test_case.py
+++ b/typ/test_case.py
@@ -15,8 +15,6 @@
 import shlex
 import unittest
 
-from StringIO import StringIO
-
 from typ import host as typ_host
 
 
@@ -33,12 +31,12 @@
             dirname = host.dirname(path)
             if dirname:
                 host.maybe_mkdir(dirname)
-            host.write(path, contents)
+            host.write_binary_file(path, contents)
 
     def _read_files(self, host, tmpdir):
         out_files = {}
         for f in host.files_under(tmpdir):
-            out_files[f] = host.read(tmpdir, f)
+            out_files[f] = host.read_binary_file(tmpdir, f)
         return out_files
 
     def assert_files(self, expected_files, actual_files, files_to_ignore=None):
@@ -57,11 +55,11 @@
 
     def check(self, cmd=None, stdin=None, env=None, files=None,
               prog=None, cwd=None, host=None,
-              ret=None, out=None, err=None, exp_files=None):
+              ret=None, out=None, err=None, exp_files=None,
+              files_to_ignore=None):
         # Too many arguments pylint: disable=R0913
         prog = prog or self.prog
         host = host or self.host or self.make_host()
-        stdin_io = StringIO(stdin) if stdin else None
         argv = shlex.split(cmd) if isinstance(cmd, basestring) else cmd or []
 
         try:
@@ -73,7 +71,7 @@
             if cwd:
                 host.chdir(cwd)
 
-            result = self.call(host, prog + argv, stdin=stdin_io, env=env)
+            result = self.call(host, prog + argv, stdin=stdin, env=env)
 
             actual_ret, actual_out, actual_err = result
             actual_files = self._read_files(host, tmpdir)
@@ -88,6 +86,6 @@
         if err is not None:
             self.assertEqual(actual_err, err)
         if exp_files:
-            self.assert_files(exp_files, actual_files)
+            self.assert_files(exp_files, actual_files, files_to_ignore)
 
         return actual_ret, actual_out, actual_err, actual_files
diff --git a/typ/tests/test_case_test.py b/typ/tests/test_case_test.py
new file mode 100644
index 0000000..3fb1c47
--- /dev/null
+++ b/typ/tests/test_case_test.py
@@ -0,0 +1,42 @@
+# Copyright 2014 Dirk Pranke. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import sys
+
+from typ import test_case
+
+class TestMainTestCase(test_case.MainTestCase):
+    def test_basic(self):
+        files = {
+            'test.py': """
+import os
+import sys
+print "in:", sys.stdin.read()
+print "out:", os.environ['TEST_VAR']
+print >>sys.stderr, "err"
+with open("../results", "w") as fp:
+  fp.write(open("../input").read() + " written")
+""",
+            'input': 'results',
+            'subdir/x': 'y',
+        }
+        exp_files = files.copy()
+        exp_files['results'] = 'results written'
+        self.check(prog=[sys.executable, '../test.py'],
+                   stdin='hello on stdin',
+                   env={'TEST_VAR': 'foo'},
+                   cwd='subdir',
+                   files=files,
+                   ret=0, out='in: hello on stdin\nout: foo\n',
+                   err='err\n', exp_files=exp_files)