Example #1
0
    def test_create_output_path_on_windows(self):
        with mock.patch("sys.platform", new="win32"):
            with mock.patch("os.environ", new={}):
                output_path = "output_path"
                test_name = "_" * 400
                test_output = create_output_path(output_path, test_name)
                self.assertEqual(len(test_output), 260 - 100 + 1)

            with mock.patch("os.environ",
                            new={"VUNIT_TEST_OUTPUT_PATH_MARGIN": "-1000"}):
                output_path = "output_path"
                test_name = "_" * 400
                test_output = create_output_path(output_path, test_name)
                self.assertEqual(
                    test_output,
                    join(abspath(output_path),
                         test_name + "_" + hash_string(test_name)))

            with mock.patch("os.environ",
                            new={"VUNIT_SHORT_TEST_OUTPUT_PATHS": ""}):
                output_path = "output_path"
                test_name = "_" * 400
                test_output = create_output_path(output_path, test_name)
                self.assertEqual(
                    test_output,
                    join(abspath(output_path), hash_string(test_name)))
Example #2
0
    def test_create_output_path_on_linux(self):
        with mock.patch("sys.platform", new="linux"):
            with mock.patch("os.environ", new={}):
                output_path = "output_path"
                test_name = "_" * 400
                test_output = create_output_path(output_path, test_name)
                self.assertEqual(
                    test_output,
                    join(abspath(output_path),
                         test_name + "_" + hash_string(test_name)))

                output_path = "output_path"
                test_name = "123._-+"
                test_output = create_output_path(output_path, test_name)
                self.assertEqual(
                    test_output,
                    join(abspath(output_path),
                         test_name + "_" + hash_string(test_name)))

                output_path = "output_path"
                test_name = "#<>:"
                safe_name = "____"
                test_output = create_output_path(output_path, test_name)
                self.assertEqual(
                    test_output,
                    join(abspath(output_path),
                         safe_name + "_" + hash_string(test_name)))
Example #3
0
 def test_runs_testcases_in_order(self):
     test_case1 = self.create_test("test1", True)
     test_case2 = self.create_test("test2", False)
     test_list = TestList()
     test_list.add_test(test_case1)
     test_list.add_test(test_case2)
     self.runner.run(test_list)
     test_case1.run.assert_called_once_with(create_output_path(self.output_path, "test1"))
     test_case2.run.assert_called_once_with(create_output_path(self.output_path, "test2"))
     self.assertEqual(self._tests, ["test1", "test2"])
     self.assertTrue(self.report.result_of("test1").passed)
     self.assertTrue(self.report.result_of("test2").failed)
Example #4
0
 def test_runs_testcases_in_order(self):
     test_case1 = self.create_test("test1", True)
     test_case2 = self.create_test("test2", False)
     test_list = TestList()
     test_list.add_test(test_case1)
     test_list.add_test(test_case2)
     self.runner.run(test_list)
     test_case1.run.assert_called_once_with(
         create_output_path(self.output_path, "test1"))
     test_case2.run.assert_called_once_with(
         create_output_path(self.output_path, "test2"))
     self.assertEqual(self._tests, ["test1", "test2"])
     self.assertTrue(self.report.result_of("test1").passed)
     self.assertTrue(self.report.result_of("test2").failed)
Example #5
0
    def test_create_output_path_on_linux(self):
        with mock.patch("sys.platform", new="linux"):
            with mock.patch("os.environ", new={}):
                output_path = "output_path"
                test_name = "_" * 400
                test_output = create_output_path(output_path, test_name)
                self.assertEqual(test_output, join(abspath(output_path), test_name + "_" + hash_string(test_name)))

                output_path = "output_path"
                test_name = "123._-+"
                test_output = create_output_path(output_path, test_name)
                self.assertEqual(test_output, join(abspath(output_path), test_name + "_" + hash_string(test_name)))

                output_path = "output_path"
                test_name = "#<>:"
                safe_name = "____"
                test_output = create_output_path(output_path, test_name)
                self.assertEqual(test_output, join(abspath(output_path), safe_name + "_" + hash_string(test_name)))
Example #6
0
    def test_create_output_path_on_windows(self):
        with mock.patch("sys.platform", new="win32"):
            with mock.patch("os.environ", new={}):
                output_path = "output_path"
                test_name = "_" * 400
                test_output = create_output_path(output_path, test_name)
                self.assertEqual(len(test_output), 260 - 100 + 1)

            with mock.patch("os.environ", new={"VUNIT_TEST_OUTPUT_PATH_MARGIN": "-1000"}):
                output_path = "output_path"
                test_name = "_" * 400
                test_output = create_output_path(output_path, test_name)
                self.assertEqual(test_output, join(abspath(output_path), test_name + "_" + hash_string(test_name)))

            with mock.patch("os.environ", new={"VUNIT_SHORT_TEST_OUTPUT_PATHS": ""}):
                output_path = "output_path"
                test_name = "_" * 400
                test_output = create_output_path(output_path, test_name)
                self.assertEqual(test_output, join(abspath(output_path), hash_string(test_name)))
Example #7
0
    def test_fail_fast(self):
        report = TestReport()
        runner = TestRunner(report, self.output_path, fail_fast=True)

        test_case1 = self.create_test("test1", True)
        test_case2 = self.create_test("test2", False)
        test_list = TestList()
        test_list.add_test(test_case1)
        test_list.add_test(test_case2)
        try:
            runner.run(test_list)
        except KeyboardInterrupt:
            pass
        test_case1.run.assert_called_once_with(
            create_output_path(self.output_path, "test1"))
        test_case2.run.assert_called_once_with(
            create_output_path(self.output_path, "test2"))
        self.assertEqual(self._tests, ["test1", "test2"])
        self.assertTrue(report.result_of("test1").passed)
        self.assertTrue(report.result_of("test2").failed)
Example #8
0
    def test_runs_testcases_in_order(self, tempdir):
        report = TestReport()
        runner = TestRunner(report, tempdir)

        order = []
        test_case1 = self.create_test("test1", True, order=order)
        test_case2 = self.create_test("test2", False, order=order)
        test_case3 = self.create_test("test3", True, order=order)
        test_list = TestList()
        test_list.add_test(test_case1)
        test_list.add_test(test_case2)
        test_list.add_test(test_case3)
        runner.run(test_list)
        self.assertEqual(test_case1.output_path, create_output_path(tempdir, "test1"))
        self.assertEqual(test_case2.output_path, create_output_path(tempdir, "test2"))
        self.assertEqual(test_case3.output_path, create_output_path(tempdir, "test3"))
        self.assertEqual(order, ["test1", "test2", "test3"])
        self.assertTrue(report.result_of("test1").passed)
        self.assertTrue(report.result_of("test2").failed)
        self.assertTrue(report.result_of("test3").passed)
Example #9
0
    def test_runs_testcases_in_order(self, tempdir):
        report = TestReport()
        runner = TestRunner(report, tempdir)

        order = []
        test_case1 = self.create_test("test1", True, order=order)
        test_case2 = self.create_test("test2", False, order=order)
        test_case3 = self.create_test("test3", True, order=order)
        test_list = TestList()
        test_list.add_test(test_case1)
        test_list.add_test(test_case2)
        test_list.add_test(test_case3)
        runner.run(test_list)
        self.assertEqual(test_case1.output_path, create_output_path(tempdir, "test1"))
        self.assertEqual(test_case2.output_path, create_output_path(tempdir, "test2"))
        self.assertEqual(test_case3.output_path, create_output_path(tempdir, "test3"))
        self.assertEqual(order, ["test1", "test2", "test3"])
        self.assertTrue(report.result_of("test1").passed)
        self.assertTrue(report.result_of("test2").failed)
        self.assertTrue(report.result_of("test3").passed)
Example #10
0
    def test_fail_fast(self, tempdir):
        report = TestReport()
        runner = TestRunner(report, tempdir, fail_fast=True)

        order = []
        test_case1 = self.create_test("test1", True, order=order)
        test_case2 = self.create_test("test2", False, order=order)
        test_case3 = self.create_test("test3", True, order=order)
        test_list = TestList()
        test_list.add_test(test_case1)
        test_list.add_test(test_case2)
        test_list.add_test(test_case3)
        try:
            runner.run(test_list)
        except KeyboardInterrupt:
            pass
        self.assertEqual(test_case1.output_path, create_output_path(tempdir, "test1"))
        self.assertEqual(test_case2.output_path, create_output_path(tempdir, "test2"))
        self.assertEqual(test_case3.called, False)
        self.assertEqual(order, ["test1", "test2"])
        self.assertTrue(report.result_of("test1").passed)
        self.assertTrue(report.result_of("test2").failed)
Example #11
0
    def test_fail_fast(self, tempdir):
        report = TestReport()
        runner = TestRunner(report, tempdir, fail_fast=True)

        order = []
        test_case1 = self.create_test("test1", True, order=order)
        test_case2 = self.create_test("test2", False, order=order)
        test_case3 = self.create_test("test3", True, order=order)
        test_list = TestList()
        test_list.add_test(test_case1)
        test_list.add_test(test_case2)
        test_list.add_test(test_case3)
        try:
            runner.run(test_list)
        except KeyboardInterrupt:
            pass
        self.assertEqual(test_case1.output_path, create_output_path(tempdir, "test1"))
        self.assertEqual(test_case2.output_path, create_output_path(tempdir, "test2"))
        self.assertEqual(test_case3.called, False)
        self.assertEqual(order, ["test1", "test2"])
        self.assertTrue(report.result_of("test1").passed)
        self.assertTrue(report.result_of("test2").failed)