Змея / Говнокод #18349 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
def execute_test_cases(api_tester):
    """
    Запускает выполнение тестов, собранных в tester.py

    :param api_tester: объект класса для тестирования API
    :type api_tester: ApiTester
    """
    test_cases = reversed([x for x in dir(TestCases) if re.match('^[A-Z][a-zA-Z\d]*$', x)])
    for test_name in test_cases:
        print "\n\n================= ** %s ** ==================" % test_name
        test_case = getattr(TestCases, test_name)
        method = re.sub('^_', '', re.sub('([A-Z])', '_\\1', test_name)).lower()
        test_case_variants = [x for x in dir(test_case) if re.match('^[a-z][\w\d]+$', x)]
        for variant in test_case_variants:
            getattr(api_tester, method)(getattr(test_case, variant)())

Человек узнал о магических методах.

Запостил: legacy legacy, (Updated )

Комментарии (0) RSS

Добавить комментарий

Переведи на "PHP", guest!

    А не использовать ли нам bbcode?


    8