An assertion fails when the expression is not true:
>>> val = 1
>>> assert val != 1, 'Oops, val is 1'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionError: Oops, val is 1
The assertion expression must evaluate to true for the assertion not to fail.
If you want to assert that the set length is 1, then test for equality.
You don't need quite as many backslashes either:
assert len(max_test_scores) == 1, (
"Internal error - migration 0011 - module Programs. "
"Please contact with developers - {}".format(len(max_test_scores)))