It looks to me like the result is consistent, although maybe not intuitive.
The problem is that the expressions is not actually a polynomial in
x, but a rational in
Polynomial.isPolynomial returns false).
However, the polynomial module understands it as a multivariate polynomial in the two algebraic variables
1/(5+x). This is confirmed by
Polynomial.variables. The provided expression
x/(x+5) is thus a multivariate monomial in the form of the product of the two variables and has therefore degree 2. The total degree is therefore also 2.
Does this help?
What do you need the total degree for?