示例#1
0
    def test_determine_tests_read_correct_number_of_tests_in_file(self):
        """
    Test that we can read the correct number of tests from the test file
    """
        test_directory = os.path.join(self.FILE_LOCATION,
                                      "samples/determine_tests")
        test_files = [
            file_name for file_name in os.listdir(test_directory)
            if os.path.splitext(file_name)[1] == ".py"
        ]
        for testfile in test_files:
            test_module = utils.load_module(
                os.path.join(test_directory, testfile))
            tests = [
                test.name
                for test in test_runner_helper._determine_tests([test_module])
            ]

            if ("empty" in testfile) or ("invalid"
                                         in testfile) or ("no_test"
                                                          in testfile):
                self.assertEqual(len(tests), 0)
            elif ("single" in testfile) or ("no_validate"
                                            in testfile) or ("no_match"
                                                             in testfile):
                self.assertEqual(len(tests), 1)
                for i in xrange(0, 1):
                    self.assertTrue("test{0}".format(i) in tests)
            elif "multi" in testfile:
                self.assertEqual(len(tests), 2)
                for i in xrange(0, 2):
                    self.assertTrue("test{0}".format(i) in tests)
            else:
                print testfile + " was not used as test input"
  def test_determine_tests_read_correct_total_number_of_tests_in_files(self):
    """
    Tests that determine_tests works for a list of modules
    """
    test_directory = os.path.join(self.FILE_LOCATION, "samples/determine_tests")
    test_files = [file_name for file_name in os.listdir(test_directory)
        if os.path.splitext(file_name)[1] == ".py"]
    test_modules = [utils.load_module(os.path.join(test_directory, test_file))
        for test_file in test_files]
    tests = test_runner_helper._determine_tests(test_modules)

    self.assertEqual(sum(1 for test in tests), 5)
示例#3
0
  def test_determine_tests_read_correct_total_number_of_tests_in_files(self):
    """
    Tests that determine_tests works for a list of modules
    """
    test_directory = os.path.join(self.FILE_LOCATION, "samples/determine_tests")
    test_files = [file_name for file_name in os.listdir(test_directory)
        if os.path.splitext(file_name)[1] == ".py"]
    test_modules = [utils.load_module(os.path.join(test_directory, test_file))
        for test_file in test_files]
    tests = test_runner_helper._determine_tests(test_modules)

    self.assertEqual(sum(1 for test in tests), 5)
  def test_determine_tests_generates_correct_test_object(self):
    """
    Tests that determine_tests generate correct test objects
    """
    test_directory = os.path.join(self.FILE_LOCATION, "samples/determine_tests")
    test_module = utils.load_module(os.path.join(test_directory,
                                                 "meta_test_single.py"))
    single_test_iterator = test_runner_helper._determine_tests([test_module])
    test = next(single_test_iterator)

    self.assertEqual(test.name, "test0")
    self.assertTrue(test.validation_function is not None)
    self.assertEqual(test.validation_function.__name__, "validate0")
示例#5
0
  def test_determine_tests_generates_correct_test_object(self):
    """
    Tests that determine_tests generate correct test objects
    """
    test_directory = os.path.join(self.FILE_LOCATION, "samples/determine_tests")
    test_module = utils.load_module(os.path.join(test_directory,
                                                 "meta_test_single.py"))
    single_test_iterator = test_runner_helper._determine_tests([test_module])
    test = next(single_test_iterator)

    self.assertEqual(test.name, "test0")
    self.assertTrue(test.validation_function is not None)
    self.assertEqual(test.validation_function.__name__, "validate0")
  def test_determine_tests_read_correct_number_of_tests_in_file(self):
    """
    Test that we can read the correct number of tests from the test file
    """
    test_directory = os.path.join(self.FILE_LOCATION, "samples/determine_tests")
    test_files = [file_name for file_name in os.listdir(test_directory)
        if os.path.splitext(file_name)[1] == ".py"]
    for testfile in test_files:
      test_module = utils.load_module(os.path.join(test_directory, testfile))
      tests = [test.name for test
          in test_runner_helper._determine_tests([test_module])]

      if ("empty" in testfile) or ("invalid" in testfile) or ("no_test" in testfile):
        self.assertEqual(len(tests), 0)
      elif ("single" in testfile) or ("no_validate" in testfile) or ("no_match" in testfile):
        self.assertEqual(len(tests), 1)
        for i in xrange(0, 1):
          self.assertTrue("test{0}".format(i) in tests)
      elif "multi" in testfile:
        self.assertEqual(len(tests), 2)
        for i in xrange(0, 2):
          self.assertTrue("test{0}".format(i) in tests)
      else:
        print testfile + " was not used as test input"