   defmacro doctest(mod, opts // []) do
     quote bind_quoted: binding do
       lc { name, test } inlist ExUnit.DocTest.__doctests__(mod, opts) do
+        @file '(for doctest at) ' ++ Path.relative_to_cwd(mod.__info__(:compile)[:source])
         def unquote(name)(_), do: unquote(test)
       end
     end

    location = [line: line, file: Path.relative_to_cwd(file)]
    stack    = Macro.escape [{ module, :__MODULE__, 0, location }]

    exc_filter_fn = fn
      { _, {:error, _, _} } -> true
      _ -> false
    end

    exceptions_num = Enum.count exprs, exc_filter_fn
    if exceptions_num > 1 do
      # Format the info about error location as if it were a part of the stacktrace
      { fun, arity } = fun_arity
      error_info = "    #{file}:#{line}: #{inspect module}.#{fun}/#{arity}"
      raise Error, message: "multiple exceptions in one doctest case are not supported.\n#{error_info}"
    end

    { tests, whole_expr } = Enum.map_reduce exprs, "", fn {expr, expected}, acc ->
      { test_case_content(expr, expected, module, line, file, stack), acc <> expr <> "\n" }
    end
    whole_expr = String.strip(whole_expr)

    exception = case Enum.find(exprs, exc_filter_fn) do
      { _, {:error, exception, message} } ->
        inspect(exception) <> " with message " <> message
      nil ->
        "nothing"
    end

    quote do
      unquote_splicing(test_import(module, do_import))
      unquote(gen_code_for_tests(tests, whole_expr, exception, stack))
    end
  end

  defp gen_code_for_tests(tests, whole_expr, exception, stack) do

    moduledocs ++ docs
  end

  defp extract_from_moduledoc({_, doc}) when doc in [false, nil], do: []

  defp extract_from_moduledoc({line, doc}) do
    extract_tests(line, doc)
  end

  defp extract_from_doc({_, _, _, _, doc}) when doc in [false, nil], do: []

  defp extract_from_doc({ fa, line, _, _, doc}) do
    lc test inlist extract_tests(line, doc) do
