   end
 
   test :open_file_without_modes do
-    { :ok, file } = File.open(File.expand_path("../fixtures/foo.txt", __FILE__))
+    { :ok, file } = File.open(fixture_path("foo.txt"))
     assert IO.gets(file, "") == "FOO\n"
     assert File.close(file) == :ok
   end
 
   test :open_file_with_charlist do
-    { :ok, file } = File.open(File.expand_path("../fixtures/foo.txt", __FILE__), [:charlist])
+    { :ok, file } = File.open(fixture_path("foo.txt"), [:charlist])
     assert IO.gets(file, "") == 'FOO\n'
     assert File.close(file) == :ok
   end
 
   test :open_utf8_by_default do
-    { :ok, file } = File.open(File.expand_path("../fixtures/utf8.txt", __FILE__))
+    { :ok, file } = File.open(fixture_path("utf8.txt"))
     assert IO.gets(file, "") == "Русский\n"
     assert File.close(file) == :ok
   end
 
   test :open_readonly_by_default do
-    { :ok, file } = File.open(File.expand_path("../fixtures/utf8.txt", __FILE__))
+    { :ok, file } = File.open(fixture_path("foo.txt"))
     assert_raise ArgumentError, fn -> IO.write(file, "foo") end
     assert File.close(file) == :ok
   end
 
   test :open_with_write_permission do
-    try do
-      { :ok, file } = File.open("test/elixir/tmp_test.txt", [:write])
+    fixture = fixture_path("tmp_text.txt")
+    try do
+      { :ok, file } = File.open(fixture, [:write])
       assert IO.write(file, "foo") == :ok
       assert File.close(file) == :ok
-      assert File.read('test/elixir/tmp_test.txt') == { :ok, "foo" }
-    after
-      File.rm('test/elixir/tmp_test.txt')
+      assert File.read(fixture) == { :ok, "foo" }
+    after
+      File.rm(fixture)
     end
   end
 
   test :open_utf8_and_charlist do
-    { :ok, file } = File.open(File.expand_path("../fixtures/utf8.txt", __FILE__), [:charlist])
+    { :ok, file } = File.open(fixture_path("utf8.txt"), [:charlist])
     assert IO.gets(file, "") == [1056,1091,1089,1089,1082,1080,1081,10]
     assert File.close(file) == :ok
   end
 
   test :open_respects_encoding do
-    { :ok, file } = File.open(File.expand_path("../fixtures/utf8.txt", __FILE__), [{:encoding, :latin1}])
+    { :ok, file } = File.open(fixture_path("utf8.txt"), [{:encoding, :latin1}])
     assert IO.gets(file, "") == <<195,144,194,160,195,145,194,131,195,145,194,129,195,145,194,129,195,144,194,186,195,144,194,184,195,144,194,185,10>>
     assert File.close(file) == :ok
   end


  test :exists do
    assert File.exists?(__FILE__)
    assert File.exists?(File.expand_path("../fixtures/foo.txt", __FILE__))
    assert File.exists?(File.expand_path("../fixtures/", __FILE__))

    refute File.exists?("fixtures/missing.txt")
    refute File.exists?("_missing.txt")
  end



defmodule FileTest do
  use ExUnit.Case

  def fixture_path() do
    File.expand_path("../fixtures", __FILE__)
  end

  def fixture_path(extra) do
    File.join(fixture_path, extra)
  end

  test :expand_path_with_binary do
    assert File.expand_path("/foo/bar") == "/foo/bar"
