@contextmanager
def mock_get_score(earned=0, possible=1):
 with patch('lms.djangoapps.grades.new.subsection_grade.get_score') as mock_score:
  mock_score.return_value = ProblemScore(raw_earned=earned, raw_possible=possible, weighted_earned=earned, weighted_possible=possible, weight=1, graded=True, attempted=True)
  (yield mock_score)

@ contextmanager def mock_get_score ( earned = 0 , possible = 1 ) : with patch ( 'lms.djangoapps.grades.new.subsection_grade.get_score' ) as mock_score : mock_score . return_value = ProblemScore ( raw_earned = earned , raw_possible = possible , weighted_earned = earned , weighted_possible = possible , weight = 1 , graded = True , attempted = True ) ( yield mock_score )
mocks the get_score function to return a valid grade .