In some of my calculus classes, we are generally allowed to do something like
$$\int{\sqrt{\cos^2x}}\ dx = \int{\cos x}\ dx$$
with the justification that the trig function (in this particular case, cosine) is positive over "the interval", so the absolute value that should be around the trig function when the square root is gotten rid of is not necessary.
What logic is this assumption based on and why is it generally considered to be okay in certain practices of calculus? Otherwise, besides the obvious case of definite integrals where the interval is one in which the trig function is fully positive, when are we allowed to make these kinds of assumptions, in integration?
This question strays slightly into subjectivity, so if there is any objective clarification I can provide, please let me know.