Does $\Vert f \Vert_p = \sup_{\Vert g \Vert_q=1}\int fg d\mu$ fail if $f \notin L^p$?

I know that for $p \in [1,\infty]$ if $X$ is $\sigma$-finite (for the $p=\infty$ case) we have $$\Vert f \Vert_p = \sup_{\substack{g \in L^q\\\Vert g \Vert = 1}} \int_X fg d\mu.$$ I always see it stated assuming $f \in L^p$, eg on wikipedia, but I would like to apply it in a situation where this is possibly not the case. Does anyone know if it is still true in the case $\Vert f \Vert_p = \infty$?

-
If $X$ is $\sigma$-finite, you could choose $g_n = \text{sgn} (f) 1_{X_n}$ where $X_n$ is a nested collection of finite measure sets whose union is $X$. Then $\int fg_n = \int_{X_n} |f|$ and Fatou's lemma shows the desired equality. If $X$ is not $\sigma$-finite, I have no clue at present. – copper.hat Nov 8 '12 at 18:09
You mean $g_n = sgn(f) |f|^{p-1} 1_{X_n}$ I think. – user27126 Nov 8 '12 at 18:15
@copper.hat In case $p\neq \infty$ I meant $\int|f|^p = \infty$ and in case $p=\infty$ I meant $\mathrm{esssup}|f| = \infty$ and in both cases assuming $f$ is measurable. – nullUser Nov 8 '12 at 18:15
@Sanchez: Yes, you are correct! I missed the exponent on all $f$s there... – copper.hat Nov 8 '12 at 18:17
See this thread and this thread for example. – user48692 Nov 8 '12 at 18:40

If the space is $\sigma$-finite, it works. Indeed, let $\{A_n\}$ an increasing sequence of measurable sets of finite measure, and $g_n:=\chi_{A_n}\operatorname{sgn}(f_n)\chi_{\{|f|<n\}}|f|^{p-1}$. It's an increasing sequence, and by Fatou's lemma, $$+\infty\leqslant\liminf_{n\to+\infty}\int_X fg_n,$$ giving what we want.
When the space is not $\sigma$-finite, we can cheat, taking $X=\{a\}$ with the measure $\mu(\{a\})=+\infty$.